From 60f2273184915c7e7ef20c9c7de416e2d5394e4d Mon Sep 17 00:00:00 2001 From: Arun Suresh Kumar Date: Sat, 6 May 2023 10:24:39 +0530 Subject: [PATCH] Fix: Queryset evaluation --- graphene_mongo/fields.py | 2 +- graphene_mongo/fields_async.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/graphene_mongo/fields.py b/graphene_mongo/fields.py index 202bd7ad..3cef0f44 100644 --- a/graphene_mongo/fields.py +++ b/graphene_mongo/fields.py @@ -473,7 +473,7 @@ def default_resolver(self, _root, info, required_fields=None, resolved=None, **a if count: has_next_page = True if (0 if limit is None else limit) + (0 if skip is None else skip) < count else False else: - if isinstance(queryset, QuerySet): + if isinstance(queryset, QuerySet) and iterables: has_next_page = bool(queryset(pk__gt=iterables[-1].pk).limit(1).first()) else: has_next_page = False diff --git a/graphene_mongo/fields_async.py b/graphene_mongo/fields_async.py index 31e4637a..8886823d 100644 --- a/graphene_mongo/fields_async.py +++ b/graphene_mongo/fields_async.py @@ -217,7 +217,7 @@ async def default_resolver(self, _root, info, required_fields=None, resolved=Non if count: has_next_page = True if (0 if limit is None else limit) + (0 if skip is None else skip) < count else False else: - if isinstance(queryset, QuerySet): + if isinstance(queryset, QuerySet) and iterables: has_next_page = bool(await sync_to_async(queryset(pk__gt=iterables[-1].pk).limit(1).first, thread_sensitive=False, executor=ThreadPoolExecutor())()) @@ -331,7 +331,9 @@ async def connection_resolver(cls, resolver, connection_type, root, info, **args setattr(root, key, from_global_id(value)[1]) except Exception: pass - iterable = await resolver(root, info, **args) + + iterable = await resolver(root=root, info=info, **args) + if isinstance(connection_type, graphene.NonNull): connection_type = connection_type.of_type on_resolve = partial(cls.resolve_connection, connection_type, args)