mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-16 07:02:04 +03:00
Use max_limit first, if set.
This commit is contained in:
parent
d804fe48f2
commit
47a3ac2758
|
@ -127,12 +127,12 @@ class DjangoConnectionField(ConnectionField):
|
|||
return connection._meta.node.get_queryset(queryset, info)
|
||||
|
||||
@classmethod
|
||||
def resolve_connection(cls, connection, args, iterable):
|
||||
def resolve_connection(cls, connection, args, iterable, max_limit=None):
|
||||
iterable = maybe_queryset(iterable)
|
||||
if isinstance(iterable, QuerySet):
|
||||
_len = iterable.count()
|
||||
_len = max_limit or iterable.count()
|
||||
else:
|
||||
_len = len(iterable)
|
||||
_len = max_limit or len(iterable)
|
||||
connection = connection_from_list_slice(
|
||||
iterable,
|
||||
args,
|
||||
|
@ -189,7 +189,7 @@ class DjangoConnectionField(ConnectionField):
|
|||
# thus the iterable gets refiltered by resolve_queryset
|
||||
# but iterable might be promise
|
||||
iterable = queryset_resolver(connection, iterable, info, args)
|
||||
on_resolve = partial(cls.resolve_connection, connection, args)
|
||||
on_resolve = partial(cls.resolve_connection, connection, args, max_limit=max_limit)
|
||||
|
||||
if Promise.is_thenable(iterable):
|
||||
return Promise.resolve(iterable).then(on_resolve)
|
||||
|
|
Loading…
Reference in New Issue
Block a user