Closed Evgenus closed 1 year ago
I ran into https://github.com/profusion/sgqlc/issues/189 exactly, and reordering the types + using this PR does seem to fix it for me!
@barbieri Hi. Can we address this?
sorry guys, I'm bit overloaded at work. As said in the ticket, removing the sorting is not a solution as it may break it.
Right now we're sorting by name only. what if we added weighted value for kind
before that, similar to:
KIND_SORT_ORDER = {
'SCALAR': 0,
'ENUM': 1,
'INPUT_OBJECT': 2,
'INTERFACE': 3,
'OBJECT': 4,
'UNION': 5,
}
def get_type_sort_key(t):
return (KIND_SORT_ORDER[t['kind']], t['name'])
# ...
class CodeGen:
# ...
def __init__(self, schema_name, schema, writer, docstrings):
# ...
self.types = sorted(schema['types'], key=get_type_sort_key)
Could you check if that one solves the issue? Otherwise we'd need to add toposort using the interfaces
and possibleTypes
could you please check #219
merged, pleas reopen if still an issue
Well, that might be a good idea to sort types in the file but sorting by name creates a mess with dependencies as was found in #189
fixes #189