From 9f366e93c60e1e01e635a50b8c424b93093e5ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Diemer?= Date: Mon, 2 Jul 2018 09:34:34 +0200 Subject: [PATCH] __wip__ add failed test Just to ease review. TODO: merge with next commit. --- graphene/types/tests/test_mutation.py | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/graphene/types/tests/test_mutation.py b/graphene/types/tests/test_mutation.py index df17477d..6ef5a072 100644 --- a/graphene/types/tests/test_mutation.py +++ b/graphene/types/tests/test_mutation.py @@ -158,3 +158,47 @@ def test_mutation_allow_to_have_custom_args(): assert field.description == 'Create a user' assert field.deprecation_reason == 'Is deprecated' assert field.type == NonNull(CreateUser) + + +def test_mutation_as_subclass(): + class BaseCreateUser(Mutation): + + class Arguments: + name = String() + + name = String() + + def mutate(self, info, **args): + return args + + class CreateUserWithPlanet(BaseCreateUser): + + class Arguments(BaseCreateUser.Arguments): + planet = String() + + planet = String() + + def mutate(self, info, **args): + return CreateUserWithPlanet(**args) + + class MyMutation(ObjectType): + create_user_with_planet = CreateUserWithPlanet.Field() + + class Query(ObjectType): + a = String() + + schema = Schema(query=Query, mutation=MyMutation) + result = schema.execute(''' mutation mymutation { + createUserWithPlanet(name:"Peter", planet: "earth") { + name + planet + } + } + ''') + assert not result.errors + assert result.data == { + 'createUserWithPlanet': { + 'name': 'Peter', + 'planet': 'earth', + } + }