mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-13 10:00:39 +03:00
Fixed ClientIDMutation GraphQL type name. Fixed #148
This commit is contained in:
parent
de424f7d21
commit
b9695c877a
|
@ -66,3 +66,37 @@ def test_node_connection_should_have_edge():
|
||||||
edges_type = connection_fields['edges'].type
|
edges_type = connection_fields['edges'].type
|
||||||
assert isinstance(edges_type, GraphQLList)
|
assert isinstance(edges_type, GraphQLList)
|
||||||
assert edges_type.of_type == schema.T(edge)
|
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'
|
||||||
|
|
|
@ -176,6 +176,8 @@ class RelayMutationMeta(MutationMeta):
|
||||||
if not cls._meta.abstract:
|
if not cls._meta.abstract:
|
||||||
assert hasattr(
|
assert hasattr(
|
||||||
cls, 'mutate_and_get_payload'), 'You have to implement mutate_and_get_payload'
|
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
|
return cls
|
||||||
|
|
||||||
def construct_arguments(cls, items):
|
def construct_arguments(cls, items):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user