mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 09:36:44 +03:00
Merge pull request #855 from cherls/default-mutation-field-description
Default mutation field description
This commit is contained in:
commit
37a6c01839
|
@ -85,7 +85,7 @@ class Mutation(ObjectType):
|
||||||
args=cls._meta.arguments,
|
args=cls._meta.arguments,
|
||||||
resolver=cls._meta.resolver,
|
resolver=cls._meta.resolver,
|
||||||
name=name,
|
name=name,
|
||||||
description=description,
|
description=description or cls._meta.description,
|
||||||
deprecation_reason=deprecation_reason,
|
deprecation_reason=deprecation_reason,
|
||||||
required=required,
|
required=required,
|
||||||
)
|
)
|
||||||
|
|
|
@ -139,17 +139,41 @@ def test_mutation_allow_to_have_custom_args():
|
||||||
|
|
||||||
class MyMutation(ObjectType):
|
class MyMutation(ObjectType):
|
||||||
create_user = CreateUser.Field(
|
create_user = CreateUser.Field(
|
||||||
|
name="createUser",
|
||||||
description="Create a user",
|
description="Create a user",
|
||||||
deprecation_reason="Is deprecated",
|
deprecation_reason="Is deprecated",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
field = MyMutation._meta.fields["create_user"]
|
field = MyMutation._meta.fields["create_user"]
|
||||||
|
assert field.name == "createUser"
|
||||||
assert field.description == "Create a user"
|
assert field.description == "Create a user"
|
||||||
assert field.deprecation_reason == "Is deprecated"
|
assert field.deprecation_reason == "Is deprecated"
|
||||||
assert field.type == NonNull(CreateUser)
|
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():
|
def test_mutation_as_subclass():
|
||||||
class BaseCreateUser(Mutation):
|
class BaseCreateUser(Mutation):
|
||||||
class Arguments:
|
class Arguments:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user