Skip to content

Commit 8d27450

Browse files
author
Chad Faurie
committed
Fixed missing query reference, Setup Tests
1 parent 0bc27e1 commit 8d27450

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

graphene_mongo/fields.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def fields(self):
104104
def get_query(cls, model, info, **args):
105105

106106
if not callable(getattr(model, 'objects', None)):
107-
return []
107+
return [], 0
108108

109109
objs = model.objects()
110110
if args:
@@ -147,7 +147,7 @@ def get_query(cls, model, info, **args):
147147
# https://github.com/graphql-python/graphene-mongo/issues/20
148148
objs = objs[-(last+1):]
149149

150-
return {'objs': objs, 'length': list_length}
150+
return objs, list_length
151151

152152
# noqa
153153
@classmethod
@@ -161,14 +161,7 @@ def merge_querysets(cls, default_queryset, queryset):
161161
def connection_resolver(cls, resolver, connection, model, root, info, **args):
162162
iterable = resolver(root, info, **args)
163163
if not iterable:
164-
iterable = cls.get_query(model, info, **args)
165-
166-
if 'objs' in query:
167-
iterable = query['objs']
168-
_len = query['length']
169-
else:
170-
iterable = query
171-
_len = len(iterable)
164+
iterable, _len = cls.get_query(model, info, **args)
172165
else:
173166
_len = len(iterable)
174167
connection = connection_from_list_slice(

graphene_mongo/tests/test_relay_query.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ class Query(graphene.ObjectType):
413413
firstName
414414
}
415415
}
416+
pageInfo {
417+
hasNextPage
418+
hasPreviousPage
419+
startCursor
420+
endCursor
421+
}
416422
}
417423
}
418424
'''
@@ -431,7 +437,13 @@ class Query(graphene.ObjectType):
431437
'firstName': 'Grant'
432438
}
433439
}
434-
]
440+
],
441+
'pageInfo': {
442+
'hasNextPage': True,
443+
'hasPreviousPage': False,
444+
'startCursor': 'xxx',
445+
'endCursor': 'xxx'
446+
}
435447
}
436448
}
437449
schema = graphene.Schema(query=Query)

0 commit comments

Comments
 (0)