In this PR we addressed the issue with broken fragments merging. Historically, hiku had no support for unions/interfaces so fragment merging was ok. But things went in the wrong direction after we added unions/interfaces support + fragments support.
Fragments merging (fields merging to be more accurate) has its rules in graphql spec, and we did not comply to them. So why thought ?
Hiku architecture was built without fragments in mind, that is - engine and denormalization modules could not work with fragments. So to avoid complex rewriting of the engine and denormalization modules, we decided to merge fragments to avoid field duplication - the hardest thing to support in the engine.
In this PR, we try to mimic graphql-py behavior or merging fields:
We removed complex merging in query parsing step, now all fields and fragments are stored in hiku ast as is
In engine we adapted SplitQuery to group fields and link:
Fields are leaf nodes so it is safe to take first field from fields_info (list of field instances) as long as field args are the same
Same link is collected and will be merged before schedule_link call, so that no duplicated links will be processed
Cache works as previous but hashes are changed sihce link node fields are merged
Denormalize adapted to work with links/fields resolved multiple times and checks that field already presents in result skipping its serialization
So basically we moved handling of fields merging to engine/denormalization stage and simplified parsing.
Some other changes:
Refactor SplitQuery types, introduce FieldInfo and LinkInfo instead of tuples
Refactor GroupQuery to use FieldInfo/LinkInfo
Fix cache tests
Drop fragments hack from result.py:Proxy since we now provide proper Proxy to index for each fragment
Add name for Fragment, if name is None - this is an InlineFragment
Node.fragments_map only returns named fragments map
In this PR we addressed the issue with broken fragments merging. Historically, hiku had no support for unions/interfaces so fragment merging was ok. But things went in the wrong direction after we added unions/interfaces support + fragments support.
Fragments merging (fields merging to be more accurate) has its rules in graphql spec, and we did not comply to them. So why thought ?
Hiku architecture was built without fragments in mind, that is - engine and denormalization modules could not work with fragments. So to avoid complex rewriting of the engine and denormalization modules, we decided to merge fragments to avoid field duplication - the hardest thing to support in the engine.
In this PR, we try to mimic graphql-py behavior or merging fields:
schedule_link
call, so that no duplicated links will be processedSo basically we moved handling of fields merging to engine/denormalization stage and simplified parsing.
Some other changes: