Skip to content

Commit 0bc27e1

Browse files
author
noodlespace
authored
Fix to update hasNextPage, was always false before
hasNextPage was always false not matter what the filter criteria were, pushed through list_length to fix this from get_query
1 parent f7229dc commit 0bc27e1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

graphene_mongo/fields.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,16 @@ def get_query(cls, model, info, **args):
138138
if before is not None:
139139
_before = int(from_global_id(before)[-1])
140140
objs = objs[:_before]
141+
# Not sure if this is in the correct place yet
142+
list_length = objs.count()
141143

142144
if first is not None:
143145
objs = objs[:first]
144146
if last is not None:
145147
# https://github.com/graphql-python/graphene-mongo/issues/20
146148
objs = objs[-(last+1):]
147149

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

150152
# noqa
151153
@classmethod
@@ -160,7 +162,15 @@ def connection_resolver(cls, resolver, connection, model, root, info, **args):
160162
iterable = resolver(root, info, **args)
161163
if not iterable:
162164
iterable = cls.get_query(model, info, **args)
163-
_len = len(iterable)
165+
166+
if 'objs' in query:
167+
iterable = query['objs']
168+
_len = query['length']
169+
else:
170+
iterable = query
171+
_len = len(iterable)
172+
else:
173+
_len = len(iterable)
164174
connection = connection_from_list_slice(
165175
iterable,
166176
args,

0 commit comments

Comments
 (0)