Skip to content

Commit 81eb81a

Browse files
committed
Fix arguments to connection_from_list_slice
1 parent 9b3344d commit 81eb81a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

graphene_django/fields.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,23 @@ def resolve_queryset(cls, connection, queryset, info, args):
133133
def resolve_connection(cls, connection, args, iterable, max_limit=None):
134134
iterable = maybe_queryset(iterable)
135135

136-
max_limit = max_limit or 0
137136
if isinstance(iterable, QuerySet):
138137
list_length = iterable.count()
139-
list_slice_length = max(max_limit, list_length)
138+
list_slice_length = (
139+
min(max_limit, list_length) if max_limit is not None else list_length
140+
)
140141
else:
141142
list_length = len(iterable)
142-
list_slice_length = max(max_limit, list_length)
143+
list_slice_length = (
144+
min(max_limit, list_length) if max_limit is not None else list_length
145+
)
143146

144147
after = get_offset_with_default(args.get("after"), -1) + 1
145-
list_slice_length += after
146148

147149
connection = connection_from_list_slice(
148-
iterable,
150+
iterable[after:],
149151
args,
150-
slice_start=0,
152+
slice_start=after,
151153
list_length=list_length,
152154
list_slice_length=list_slice_length,
153155
connection_type=connection,

graphene_django/tests/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ class Query(graphene.ObjectType):
11271127

11281128

11291129
def test_should_have_next_page(graphene_settings):
1130-
graphene_settings.RELAY_CONNECTION_MAX_LIMIT = 4
1130+
graphene_settings.RELAY_CONNECTION_MAX_LIMIT = 6
11311131
reporters = [Reporter(**kwargs) for kwargs in REPORTERS]
11321132
Reporter.objects.bulk_create(reporters)
11331133
db_reporters = Reporter.objects.all()

0 commit comments

Comments
 (0)