File tree Expand file tree Collapse file tree 1 file changed +42
-8
lines changed Expand file tree Collapse file tree 1 file changed +42
-8
lines changed Original file line number Diff line number Diff line change @@ -275,14 +275,14 @@ class Query(graphene.ObjectType):
275
275
articles = MongoengineConnectionField (ArticleNode )
276
276
277
277
query = '''
278
- query ArticleQuery {
279
- articles(headline: "World") {
280
- edges {
281
- node {
282
- headline
278
+ query ArticlesQuery {
279
+ articles(headline: "World") {
280
+ edges {
281
+ node {
282
+ headline
283
+ }
283
284
}
284
285
}
285
- }
286
286
}
287
287
'''
288
288
expected = {
@@ -302,8 +302,42 @@ class Query(graphene.ObjectType):
302
302
assert result .data == expected
303
303
304
304
305
- def test_should_first_n ():
306
- pass
305
+ def test_should_custom_kwargs ():
306
+
307
+ class Query (graphene .ObjectType ):
308
+
309
+ editors = graphene .List (EditorType , first = graphene .Int ())
310
+
311
+ def resolve_editors (self , * args , ** kwargs ):
312
+ editors = Editor .objects ()
313
+ if 'first' in kwargs :
314
+ editors = editors [:kwargs ['first' ]]
315
+ return list (editors )
316
+
317
+ query = '''
318
+ query EditorQuery {
319
+ editors(first: 2) {
320
+ firstName,
321
+ lastName
322
+ }
323
+ }
324
+ '''
325
+ expected = {
326
+ 'editors' :[
327
+ {
328
+ 'firstName' : 'Penny' ,
329
+ 'lastName' : 'Hardaway'
330
+ },
331
+ {
332
+ 'firstName' : 'Grant' ,
333
+ 'lastName' : 'Hill'
334
+ }
335
+ ]
336
+ }
337
+ schema = graphene .Schema (query = Query )
338
+ result = schema .execute (query )
339
+ assert not result .errors
340
+ assert all (item in result .data ['editors' ] for item in expected ['editors' ])
307
341
308
342
# TODO:
309
343
def test_should_paging ():
You can’t perform that action at this time.
0 commit comments