diff --git a/docs/Makefile b/docs/Makefile index 7da67c31..2973acec 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -223,3 +223,7 @@ dummy: $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy @echo @echo "Build finished. Dummy builder generates no files." + +.PHONY: livehtml +livehtml: + sphinx-autobuild -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html diff --git a/docs/execution/index.rst b/docs/execution/index.rst index beb4e3b1..849832d4 100644 --- a/docs/execution/index.rst +++ b/docs/execution/index.rst @@ -2,6 +2,38 @@ Execution ========= +For executing a query a schema, you can directly call the ``execute`` method on it. + + +.. code:: python + + schema = graphene.Schema(...) + result = schema.execute('{ name }') + +``result`` represents he result of execution. ``result.data`` is the result of executing the query, ``result.errors`` is ``None`` if no errors occurred, and is a non-empty list if an error occurred. + + +Context +_______ + +You can pass context to a query via ``context_value``. + + +.. code:: python + + class Query(graphene.ObjectType): + name = graphene.String() + + def resolve_name(self, args, context, info): + return context.get('name') + + schema = graphene.Schema(Query) + result = schema.execute('{ name }', context_value={'name': 'Syrus'}) + + +Middleware +__________ + .. toctree:: :maxdepth: 1