Skip to content

Commit 9f366e9

Browse files
author
Sébastien Diemer
committed
__wip__ add failed test
Just to ease review. TODO: merge with next commit.
1 parent 1b746e6 commit 9f366e9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

graphene/types/tests/test_mutation.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,47 @@ class MyMutation(ObjectType):
158158
assert field.description == 'Create a user'
159159
assert field.deprecation_reason == 'Is deprecated'
160160
assert field.type == NonNull(CreateUser)
161+
162+
163+
def test_mutation_as_subclass():
164+
class BaseCreateUser(Mutation):
165+
166+
class Arguments:
167+
name = String()
168+
169+
name = String()
170+
171+
def mutate(self, info, **args):
172+
return args
173+
174+
class CreateUserWithPlanet(BaseCreateUser):
175+
176+
class Arguments(BaseCreateUser.Arguments):
177+
planet = String()
178+
179+
planet = String()
180+
181+
def mutate(self, info, **args):
182+
return CreateUserWithPlanet(**args)
183+
184+
class MyMutation(ObjectType):
185+
create_user_with_planet = CreateUserWithPlanet.Field()
186+
187+
class Query(ObjectType):
188+
a = String()
189+
190+
schema = Schema(query=Query, mutation=MyMutation)
191+
result = schema.execute(''' mutation mymutation {
192+
createUserWithPlanet(name:"Peter", planet: "earth") {
193+
name
194+
planet
195+
}
196+
}
197+
''')
198+
assert not result.errors
199+
assert result.data == {
200+
'createUserWithPlanet': {
201+
'name': 'Peter',
202+
'planet': 'earth',
203+
}
204+
}

0 commit comments

Comments
 (0)