From a091a720942e8f9dca4cba80fa697a8303a83850 Mon Sep 17 00:00:00 2001 From: Abhinand C Date: Sat, 9 Dec 2023 14:55:45 +0530 Subject: [PATCH] fix: handle all cases, handle invalid info --- graphene_mongo/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/graphene_mongo/utils.py b/graphene_mongo/utils.py index 51fc5b2..ffc8422 100644 --- a/graphene_mongo/utils.py +++ b/graphene_mongo/utils.py @@ -182,19 +182,18 @@ def has_page_info(info): info (ResolveInfo) Returns: - dict: Returned from collect_query_fields + bool: True if it received pageinfo """ fragments = {} + if not info: + return True # Returning True if invalid info is provided node = ast_to_dict(info.field_nodes[0]) - for name, value in info.fragments.items(): fragments[name] = ast_to_dict(value) query = collect_query_fields(node, fragments) - # if "PageInfo" in query: - # return query["edges"]["node"].keys() - return bool("PageInfo" in query) + return next((True for x in query.keys() if x.lower() == "pageinfo"), False) def ast_to_dict(node, include_loc=False):