Skip to content

Commit

Permalink
Merge pull request #502 from Thibaut-Fatus/patch-1
Browse files Browse the repository at this point in the history
Doc was missing for using variables in queries
  • Loading branch information
syrusakbary authored Jul 12, 2017
2 parents 3e62fcf + c155b7a commit 557ec44
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/execution/execute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ You can pass context to a query via ``context_value``.
schema = graphene.Schema(Query)
result = schema.execute('{ name }', context_value={'name': 'Syrus'})
Variables
_______

You can pass variables to a query via ``variable_values``.


.. code:: python
class Query(graphene.ObjectType):
user = graphene.Field(User)
def resolve_user(self, args, context, info):
return context.get('user')
schema = graphene.Schema(Query)
result = schema.execute(
'''query getUser($id: ID) {
user(id: $id) {
id
firstName
lastName
}
}''',
variable_values={'id': 12},
)

0 comments on commit 557ec44

Please sign in to comment.