diff --git a/graphene/types/tests/test_mutation.py b/graphene/types/tests/test_mutation.py index 3ecefe2f..bc722b4b 100644 --- a/graphene/types/tests/test_mutation.py +++ b/graphene/types/tests/test_mutation.py @@ -148,3 +148,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', + } + } diff --git a/graphene/utils/props.py b/graphene/utils/props.py index 67fa8a4e..5ef3ba0a 100644 --- a/graphene/utils/props.py +++ b/graphene/utils/props.py @@ -10,4 +10,6 @@ _all_vars = set(dir(_OldClass) + dir(_NewClass)) def props(x): - return {key: value for key, value in vars(x).items() if key not in _all_vars} + return { + key: vars(x).get(key, getattr(x, key)) for key in dir(x) if key not in _all_vars + }