From c5b2281e222fd944ab5ad9d0b02010d519d1b8a9 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Wed, 27 Mar 2019 23:44:41 +0000 Subject: [PATCH] Update execution doc with correct way to use variables (#920) * Fix issue #890 * Change to `root` --- docs/execution/execute.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/execution/execute.rst b/docs/execution/execute.rst index 21345aa3..1c28548a 100644 --- a/docs/execution/execute.rst +++ b/docs/execution/execute.rst @@ -24,7 +24,7 @@ You can pass context to a query via ``context``. class Query(graphene.ObjectType): name = graphene.String() - def resolve_name(self, info): + def resolve_name(root, info): return info.context.get('name') schema = graphene.Schema(Query) @@ -33,7 +33,7 @@ You can pass context to a query via ``context``. 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 class Query(graphene.ObjectType): - user = graphene.Field(User) + user = graphene.Field(User, id=graphene.ID(required=True)) - def resolve_user(self, info): - return info.context.get('user') + def resolve_user(root, info, id): + return get_user_by_id(id) schema = graphene.Schema(Query) result = schema.execute(