mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-12 09:12:18 +03:00
Fix arguments to connection_from_list_slice
This commit is contained in:
parent
9b3344d5d9
commit
6fd5cc9522
|
@ -133,21 +133,23 @@ class DjangoConnectionField(ConnectionField):
|
|||
def resolve_connection(cls, connection, args, iterable, max_limit=None):
|
||||
iterable = maybe_queryset(iterable)
|
||||
|
||||
max_limit = max_limit or 0
|
||||
if isinstance(iterable, QuerySet):
|
||||
list_length = iterable.count()
|
||||
list_slice_length = max(max_limit, list_length)
|
||||
list_slice_length = (
|
||||
min(max_limit, list_length) if max_limit is not None else list_length
|
||||
)
|
||||
else:
|
||||
list_length = len(iterable)
|
||||
list_slice_length = max(max_limit, list_length)
|
||||
list_slice_length = (
|
||||
min(max_limit, list_length) if max_limit is not None else list_length
|
||||
)
|
||||
|
||||
after = get_offset_with_default(args.get("after"), -1) + 1
|
||||
list_slice_length += after
|
||||
|
||||
connection = connection_from_list_slice(
|
||||
iterable,
|
||||
iterable[after:],
|
||||
args,
|
||||
slice_start=0,
|
||||
slice_start=after,
|
||||
list_length=list_length,
|
||||
list_slice_length=list_slice_length,
|
||||
connection_type=connection,
|
||||
|
|
|
@ -1127,7 +1127,7 @@ def test_should_return_max_limit(graphene_settings):
|
|||
|
||||
|
||||
def test_should_have_next_page(graphene_settings):
|
||||
graphene_settings.RELAY_CONNECTION_MAX_LIMIT = 4
|
||||
graphene_settings.RELAY_CONNECTION_MAX_LIMIT = 6
|
||||
reporters = [Reporter(**kwargs) for kwargs in REPORTERS]
|
||||
Reporter.objects.bulk_create(reporters)
|
||||
db_reporters = Reporter.objects.all()
|
||||
|
|
Loading…
Reference in New Issue
Block a user