From c155b7a56e5963d9fafac98184603eef636c2ad0 Mon Sep 17 00:00:00 2001 From: Thibaut Fatus Date: Wed, 12 Jul 2017 18:52:46 +0200 Subject: [PATCH] Doc was missing for using variables in queries added an example --- docs/execution/execute.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/execution/execute.rst b/docs/execution/execute.rst index 17bd9071..d86fdd10 100644 --- a/docs/execution/execute.rst +++ b/docs/execution/execute.rst @@ -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}, + )