File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -158,3 +158,47 @@ class MyMutation(ObjectType):
158
158
assert field .description == 'Create a user'
159
159
assert field .deprecation_reason == 'Is deprecated'
160
160
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
+ }
You can’t perform that action at this time.
0 commit comments