mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 09:42:32 +03:00
Account for edges/node nesting in ast
This commit is contained in:
parent
17e9bd3331
commit
f585518cc1
|
@ -17,9 +17,21 @@ def model_fields_as_dict(model):
|
|||
return dict((f.name, f) for f in model._meta.get_fields())
|
||||
|
||||
|
||||
def find_model_selections(ast):
|
||||
selections = ast.selection_set.selections
|
||||
|
||||
for selection in selections:
|
||||
if selection.name.value == 'edges':
|
||||
for sub_selection in selection.selection_set.selections:
|
||||
if sub_selection.name.value == 'node':
|
||||
return sub_selection.selection_set.selections
|
||||
|
||||
return selections
|
||||
|
||||
|
||||
def get_related_fetches_for_model(model, graphql_ast):
|
||||
model_fields = model_fields_as_dict(model)
|
||||
selections = graphql_ast.selection_set.selections
|
||||
selections = find_model_selections(graphql_ast)
|
||||
|
||||
graphene_obj_type = REGISTRY.get_type_for_model(model)
|
||||
optimizations = {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user