mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Fixed mutation payload name and added tests for covering it.
This commit is contained in:
parent
d8fac58701
commit
10a3e86cc5
|
@ -19,8 +19,7 @@ class ClientIDMutation(Mutation):
|
||||||
return
|
return
|
||||||
|
|
||||||
input_class = getattr(cls, 'Input', None)
|
input_class = getattr(cls, 'Input', None)
|
||||||
name = name or cls.__name__
|
base_name = re.sub('Payload$', '', name or cls.__name__)
|
||||||
base_name = re.sub('Payload$', '', name)
|
|
||||||
|
|
||||||
assert not output, "Can't specify any output"
|
assert not output, "Can't specify any output"
|
||||||
assert not arguments, "Can't specify any arguments"
|
assert not arguments, "Can't specify any arguments"
|
||||||
|
@ -35,7 +34,8 @@ class ClientIDMutation(Mutation):
|
||||||
cls.Input = type(
|
cls.Input = type(
|
||||||
'{}Input'.format(base_name),
|
'{}Input'.format(base_name),
|
||||||
bases,
|
bases,
|
||||||
OrderedDict(input_fields, client_mutation_id=String(name='clientMutationId'))
|
OrderedDict(input_fields, client_mutation_id=String(
|
||||||
|
name='clientMutationId'))
|
||||||
)
|
)
|
||||||
|
|
||||||
arguments = OrderedDict(
|
arguments = OrderedDict(
|
||||||
|
@ -46,12 +46,13 @@ class ClientIDMutation(Mutation):
|
||||||
if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__:
|
if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__:
|
||||||
assert mutate_and_get_payload, (
|
assert mutate_and_get_payload, (
|
||||||
"{name}.mutate_and_get_payload method is required"
|
"{name}.mutate_and_get_payload method is required"
|
||||||
" in a ClientIDMutation.").format(name=name)
|
" in a ClientIDMutation.").format(name=name or cls.__name__)
|
||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
name = '{}Payload'.format(base_name)
|
name = '{}Payload'.format(base_name)
|
||||||
|
|
||||||
super(ClientIDMutation, cls).__init_subclass_with_meta__(output=None, arguments=arguments, name=name, **options)
|
super(ClientIDMutation, cls).__init_subclass_with_meta__(
|
||||||
|
output=None, arguments=arguments, name=name, **options)
|
||||||
cls._meta.fields['client_mutation_id'] = (
|
cls._meta.fields['client_mutation_id'] = (
|
||||||
Field(String, name='clientMutationId')
|
Field(String, name='clientMutationId')
|
||||||
)
|
)
|
||||||
|
|
|
@ -91,6 +91,7 @@ def test_no_mutate_and_get_payload():
|
||||||
def test_mutation():
|
def test_mutation():
|
||||||
fields = SaySomething._meta.fields
|
fields = SaySomething._meta.fields
|
||||||
assert list(fields.keys()) == ['phrase', 'client_mutation_id']
|
assert list(fields.keys()) == ['phrase', 'client_mutation_id']
|
||||||
|
assert SaySomething._meta.name == "SaySomethingPayload"
|
||||||
assert isinstance(fields['phrase'], Field)
|
assert isinstance(fields['phrase'], Field)
|
||||||
field = SaySomething.Field()
|
field = SaySomething.Field()
|
||||||
assert field.type == SaySomething
|
assert field.type == SaySomething
|
||||||
|
|
Loading…
Reference in New Issue
Block a user