mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 01:26:49 +03:00
Improve mutation test
This commit is contained in:
parent
efe77998d4
commit
e42a826078
|
@ -179,30 +179,25 @@ def test_mutation_complex_input():
|
||||||
name = String(required=True)
|
name = String(required=True)
|
||||||
email = String(required=True)
|
email = String(required=True)
|
||||||
|
|
||||||
class CreateUserSuccess(ObjectType):
|
MUTATION_PREFIX = "CreateUser"
|
||||||
|
|
||||||
|
class Success(ObjectType, type_name=f"{MUTATION_PREFIX}Success"):
|
||||||
user = Field(User, required=True)
|
user = Field(User, required=True)
|
||||||
|
|
||||||
class CreateUserError(ObjectType):
|
class Error(ObjectType, type_name=f"{MUTATION_PREFIX}Error"):
|
||||||
error_message = String(required=True)
|
error_message = String(required=True)
|
||||||
|
|
||||||
class CreateUserOutput(Union):
|
class Input(InputObjectType, type_name=f"{MUTATION_PREFIX}Input"):
|
||||||
class Meta:
|
|
||||||
types = [
|
|
||||||
CreateUserSuccess,
|
|
||||||
CreateUserError,
|
|
||||||
]
|
|
||||||
|
|
||||||
class CreateUserInput(InputObjectType):
|
|
||||||
name = String(required=True)
|
name = String(required=True)
|
||||||
email = String(required=True)
|
email = String(required=True)
|
||||||
|
|
||||||
@mutation(
|
@mutation(
|
||||||
CreateUserOutput,
|
Union.create_type(f"{MUTATION_PREFIX}Output", types=[Success, Error]),
|
||||||
required=True,
|
required=True,
|
||||||
arguments={"user": CreateUserInput(required=True)},
|
arguments={"user": Input(required=True)},
|
||||||
)
|
)
|
||||||
def create_user(root, info, user):
|
def create_user(root, info, user):
|
||||||
return CreateUserSuccess(user=User(**user))
|
return Success(user=User(**user))
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
a = String()
|
a = String()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user