Merge pull request #855 from cherls/default-mutation-field-description

Default mutation field description
This commit is contained in:
Syrus Akbary 2018-11-05 20:25:56 +01:00 committed by GitHub
commit 37a6c01839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -85,7 +85,7 @@ class Mutation(ObjectType):
args=cls._meta.arguments,
resolver=cls._meta.resolver,
name=name,
description=description,
description=description or cls._meta.description,
deprecation_reason=deprecation_reason,
required=required,
)

View File

@ -139,17 +139,41 @@ def test_mutation_allow_to_have_custom_args():
class MyMutation(ObjectType):
create_user = CreateUser.Field(
name="createUser",
description="Create a user",
deprecation_reason="Is deprecated",
required=True,
)
field = MyMutation._meta.fields["create_user"]
assert field.name == "createUser"
assert field.description == "Create a user"
assert field.deprecation_reason == "Is deprecated"
assert field.type == NonNull(CreateUser)
def test_mutation_default_args_output():
class CreateUser(Mutation):
"""Description."""
class Arguments:
name = String()
name = String()
def mutate(self, info, name):
return CreateUser(name=name)
class MyMutation(ObjectType):
create_user = CreateUser.Field()
field = MyMutation._meta.fields["create_user"]
assert field.name is None
assert field.description == "Description."
assert field.deprecation_reason is None
assert field.type == CreateUser
def test_mutation_as_subclass():
class BaseCreateUser(Mutation):
class Arguments: