File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -148,3 +148,47 @@ class MyMutation(ObjectType):
148
148
assert field .description == "Create a user"
149
149
assert field .deprecation_reason == "Is deprecated"
150
150
assert field .type == NonNull (CreateUser )
151
+
152
+
153
+ def test_mutation_as_subclass ():
154
+ class BaseCreateUser (Mutation ):
155
+
156
+ class Arguments :
157
+ name = String ()
158
+
159
+ name = String ()
160
+
161
+ def mutate (self , info , ** args ):
162
+ return args
163
+
164
+ class CreateUserWithPlanet (BaseCreateUser ):
165
+
166
+ class Arguments (BaseCreateUser .Arguments ):
167
+ planet = String ()
168
+
169
+ planet = String ()
170
+
171
+ def mutate (self , info , ** args ):
172
+ return CreateUserWithPlanet (** args )
173
+
174
+ class MyMutation (ObjectType ):
175
+ create_user_with_planet = CreateUserWithPlanet .Field ()
176
+
177
+ class Query (ObjectType ):
178
+ a = String ()
179
+
180
+ schema = Schema (query = Query , mutation = MyMutation )
181
+ result = schema .execute (''' mutation mymutation {
182
+ createUserWithPlanet(name:"Peter", planet: "earth") {
183
+ name
184
+ planet
185
+ }
186
+ }
187
+ ''' )
188
+ assert not result .errors
189
+ assert result .data == {
190
+ 'createUserWithPlanet' : {
191
+ 'name' : 'Peter' ,
192
+ 'planet' : 'earth' ,
193
+ }
194
+ }
Original file line number Diff line number Diff line change @@ -10,4 +10,6 @@ class _NewClass(object):
10
10
11
11
12
12
def props (x ):
13
- return {key : value for key , value in vars (x ).items () if key not in _all_vars }
13
+ return {
14
+ key : vars (x ).get (key , getattr (x , key )) for key in dir (x ) if key not in _all_vars
15
+ }
You can’t perform that action at this time.
0 commit comments