Skip to content

Commit c5b2281

Browse files
jkimboekampf
authored andcommitted
Update execution doc with correct way to use variables (#920)
* Fix issue #890 * Change to `root`
1 parent 21cccf4 commit c5b2281

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/execution/execute.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ You can pass context to a query via ``context``.
2424
class Query(graphene.ObjectType):
2525
name = graphene.String()
2626
27-
def resolve_name(self, info):
27+
def resolve_name(root, info):
2828
return info.context.get('name')
2929
3030
schema = graphene.Schema(Query)
@@ -33,18 +33,18 @@ You can pass context to a query via ``context``.
3333
3434
3535
Variables
36-
_______
36+
_________
3737

3838
You can pass variables to a query via ``variables``.
3939

4040

4141
.. code:: python
4242
4343
class Query(graphene.ObjectType):
44-
user = graphene.Field(User)
44+
user = graphene.Field(User, id=graphene.ID(required=True))
4545
46-
def resolve_user(self, info):
47-
return info.context.get('user')
46+
def resolve_user(root, info, id):
47+
return get_user_by_id(id)
4848
4949
schema = graphene.Schema(Query)
5050
result = schema.execute(

0 commit comments

Comments
 (0)