Graphene: Allow variables passed to schema.execute

Created on 18 Apr 2016  路  3Comments  路  Source: graphql-python/graphene

Is there a way to pass "variables" to schema.execute? In the same way Relay mutations input is passed, ideally.

It's not clear from the docs/code how I would do this.

Most helpful comment

FYI - It appears as though args has been renamed variable_values.

All 3 comments

I figured it out. It's the args keyword argument to schema.execute. It should be a dict (or other map type) and the keys should be camelCase. For example:

schema.execute(
    '''
    mutation UpdateItem($input_key: UpdateItemMutationInput!) {
        updateItem(input: $input_key)
    }
    ''',
    args={
        'input_key': {
            'clientMutationId': 'whatever',
            'someOtherInputValue': 42,
        }
    },
)

FYI - It appears as though args has been renamed variable_values.

Variables (instead of variable_values) worked for me

Was this page helpful?
0 / 5 - 0 ratings