@@ -35,8 +35,8 @@ def get_model_reference_fields(model, excluding=None):
35
35
attributes = dict ()
36
36
for attr_name , attr in model ._fields .items ():
37
37
if attr_name in excluding or not isinstance (
38
- attr ,
39
- (mongoengine .fields .ReferenceField , mongoengine .fields .LazyReferenceField ),
38
+ attr ,
39
+ (mongoengine .fields .ReferenceField , mongoengine .fields .LazyReferenceField ),
40
40
):
41
41
continue
42
42
attributes [attr_name ] = attr
@@ -45,7 +45,7 @@ def get_model_reference_fields(model, excluding=None):
45
45
46
46
def is_valid_mongoengine_model (model ):
47
47
return inspect .isclass (model ) and (
48
- issubclass (model , mongoengine .Document ) or issubclass (model , mongoengine .EmbeddedDocument )
48
+ issubclass (model , mongoengine .Document ) or issubclass (model , mongoengine .EmbeddedDocument )
49
49
)
50
50
51
51
@@ -182,19 +182,18 @@ def has_page_info(info):
182
182
info (ResolveInfo)
183
183
184
184
Returns:
185
- dict: Returned from collect_query_fields
185
+ bool: True if it received pageinfo
186
186
"""
187
187
188
188
fragments = {}
189
+ if not info :
190
+ return True # Returning True if invalid info is provided
189
191
node = ast_to_dict (info .field_nodes [0 ])
190
-
191
192
for name , value in info .fragments .items ():
192
193
fragments [name ] = ast_to_dict (value )
193
194
194
195
query = collect_query_fields (node , fragments )
195
- # if "PageInfo" in query:
196
- # return query["edges"]["node"].keys()
197
- return bool ("PageInfo" in query )
196
+ return next ((True for x in query .keys () if x .lower () == "pageinfo" ), False )
198
197
199
198
200
199
def ast_to_dict (node , include_loc = False ):
@@ -257,7 +256,7 @@ def find_skip_and_limit(first, last, after, before, count=None):
257
256
258
257
259
258
def connection_from_iterables (
260
- edges , start_offset , has_previous_page , has_next_page , connection_type , edge_type , pageinfo_type
259
+ edges , start_offset , has_previous_page , has_next_page , connection_type , edge_type , pageinfo_type
261
260
):
262
261
edges_items = [
263
262
edge_type (
@@ -281,9 +280,9 @@ def connection_from_iterables(
281
280
282
281
283
282
def sync_to_async (
284
- func : Callable = None ,
285
- thread_sensitive : bool = False ,
286
- executor : Any = None , # noqa
283
+ func : Callable = None ,
284
+ thread_sensitive : bool = False ,
285
+ executor : Any = None , # noqa
287
286
) -> Union [SyncToAsync , Callable [[Callable [..., Any ]], SyncToAsync ]]:
288
287
"""
289
288
Wrapper over sync_to_async from asgiref.sync
0 commit comments