File tree Expand file tree Collapse file tree 1 file changed +54
-2
lines changed Expand file tree Collapse file tree 1 file changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -226,9 +226,61 @@ class Query(graphene.ObjectType):
226
226
assert not result .errors
227
227
assert dict (result .data ['allEditors' ]) == expected ['allEditors' ]
228
228
229
- # TODO:
229
+
230
230
def test_should_mutate_well ():
231
- pass
231
+ class ArticleNode (MongoengineObjectType ):
232
+
233
+ class Meta :
234
+ model = Article
235
+ interfaces = (Node ,)
236
+
237
+
238
+ class CreateArticle (graphene .Mutation ):
239
+
240
+ class Arguments :
241
+ headline = graphene .String ()
242
+
243
+ article = graphene .Field (ArticleNode )
244
+
245
+ def mutate (self , info , headline ):
246
+ article = Article (
247
+ headline = headline
248
+ )
249
+ article .save ()
250
+
251
+ return CreateArticle (article = article )
252
+
253
+
254
+ class Query (graphene .ObjectType ):
255
+ node = Node .Field ()
256
+
257
+
258
+ class Mutation (graphene .ObjectType ):
259
+
260
+ create_article = CreateArticle .Field ()
261
+
262
+ query = '''
263
+ mutation ArticleCreator {
264
+ createArticle(
265
+ headline: "My Article"
266
+ ) {
267
+ article {
268
+ headline
269
+ }
270
+ }
271
+ }
272
+ '''
273
+ expected = {
274
+ 'createArticle' : {
275
+ 'article' : {
276
+ 'headline' : 'My Article'
277
+ }
278
+ }
279
+ }
280
+ schema = graphene .Schema (query = Query , mutation = Mutation )
281
+ result = schema .execute (query )
282
+ assert not result .errors
283
+ assert result .data == expected
232
284
233
285
# TODO:
234
286
def test_should_filter ():
You can’t perform that action at this time.
0 commit comments