From a0ac884bb27f83ca9d4344432e638da70f1e7643 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 22 Jan 2016 10:42:08 -0800 Subject: [PATCH] Set clientMutationId to be camelCase as defined by the graphql relay specification. Fixed #86 --- graphene/relay/tests/test_mutations.py | 2 +- graphene/relay/types.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/graphene/relay/tests/test_mutations.py b/graphene/relay/tests/test_mutations.py index 02287725..82329519 100644 --- a/graphene/relay/tests/test_mutations.py +++ b/graphene/relay/tests/test_mutations.py @@ -37,7 +37,7 @@ def test_mutation_arguments(): assert 'input' in schema.T(ChangeNumber.arguments) inner_type = ChangeNumber.input_type client_mutation_id_field = inner_type._meta.fields_map[ - 'client_mutation_id'] + 'clientMutationId'] assert issubclass(inner_type, graphene.InputObjectType) assert isinstance(client_mutation_id_field.type, graphene.NonNull) assert isinstance(client_mutation_id_field.type.of_type, graphene.String) diff --git a/graphene/relay/types.py b/graphene/relay/types.py index 672042e7..5dbae954 100644 --- a/graphene/relay/types.py +++ b/graphene/relay/types.py @@ -142,7 +142,7 @@ class Node(six.with_metaclass(NodeMeta, Interface)): class MutationInputType(InputObjectType): - client_mutation_id = String(required=True) + clientMutationId = String(required=True) class RelayMutationMeta(MutationMeta): @@ -162,7 +162,7 @@ class RelayMutationMeta(MutationMeta): class ClientIDMutation(six.with_metaclass(RelayMutationMeta, Mutation)): - client_mutation_id = String(required=True) + clientMutationId = String(required=True) class Meta: abstract = True @@ -171,6 +171,6 @@ class ClientIDMutation(six.with_metaclass(RelayMutationMeta, Mutation)): def mutate(cls, instance, args, info): input = args.get('input') payload = cls.mutate_and_get_payload(input, info) - client_mutation_id = input.get('client_mutation_id') - setattr(payload, 'client_mutation_id', client_mutation_id) + client_mutation_id = input.get('clientMutationId') or input.get('client_mutation_id') + setattr(payload, 'clientMutationId', client_mutation_id) return payload