Update execution doc with correct way to use variables (#920)

* Fix issue #890

* Change to `root`
This commit is contained in:
Jonathan Kim 2019-03-27 23:44:41 +00:00 committed by Eran Kampf
parent 21cccf4c96
commit c5b2281e22

View File

@ -24,7 +24,7 @@ You can pass context to a query via ``context``.
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
name = graphene.String() name = graphene.String()
def resolve_name(self, info): def resolve_name(root, info):
return info.context.get('name') return info.context.get('name')
schema = graphene.Schema(Query) schema = graphene.Schema(Query)
@ -33,7 +33,7 @@ You can pass context to a query via ``context``.
Variables Variables
_______ _________
You can pass variables to a query via ``variables``. You can pass variables to a query via ``variables``.
@ -41,10 +41,10 @@ You can pass variables to a query via ``variables``.
.. code:: python .. code:: python
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
user = graphene.Field(User) user = graphene.Field(User, id=graphene.ID(required=True))
def resolve_user(self, info): def resolve_user(root, info, id):
return info.context.get('user') return get_user_by_id(id)
schema = graphene.Schema(Query) schema = graphene.Schema(Query)
result = schema.execute( result = schema.execute(