Merge pull request #502 from Thibaut-Fatus/patch-1

Doc was missing for using variables in queries
This commit is contained in:
Syrus Akbary 2017-07-12 10:36:54 -07:00 committed by GitHub
commit 557ec44a13

View File

@ -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},
)