Fixed ClientIDMutation GraphQL type name. Fixed #148

This commit is contained in:
Syrus Akbary 2016-05-31 20:55:01 -07:00
parent de424f7d21
commit b9695c877a
2 changed files with 36 additions and 0 deletions

View File

@ -66,3 +66,37 @@ def test_node_connection_should_have_edge():
edges_type = connection_fields['edges'].type
assert isinstance(edges_type, GraphQLList)
assert edges_type.of_type == schema.T(edge)
def test_client_mutation_id():
class RemoveWidget(relay.ClientIDMutation):
class Input:
id = graphene.String(required=True)
deletedWidgetID = graphene.String()
@classmethod
def mutate_and_get_payload(cls, input, info):
pass
graphql_type = schema.T(RemoveWidget)
assert graphql_type.name == 'RemoveWidgetPayload'
def test_client_mutation_id_with_name():
class RemoveWidget(relay.ClientIDMutation):
class Meta:
type_name = 'RemoveWidgetCustomPayload'
class Input:
id = graphene.String(required=True)
deletedWidgetID = graphene.String()
@classmethod
def mutate_and_get_payload(cls, input, info):
pass
graphql_type = schema.T(RemoveWidget)
assert graphql_type.name == 'RemoveWidgetCustomPayload'

View File

@ -176,6 +176,8 @@ class RelayMutationMeta(MutationMeta):
if not cls._meta.abstract:
assert hasattr(
cls, 'mutate_and_get_payload'), 'You have to implement mutate_and_get_payload'
if 'type_name' not in cls._meta.original_attrs:
cls._meta.type_name = '{}Payload'.format(cls.__name__)
return cls
def construct_arguments(cls, items):