-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this PR we addressed the issue with broken fragments merging. Historically, hiku has not supported unions/interfaces so fragments merging were ok. But after we added unions/intefaces support + fragments support, things went in the wrong direction. Fragments merging (fields merging to be more accurate) has its own rules in graphql spec and we did not complied. So why thought ? Hiku arhitecture was build without fragments in mind, that is - engine and denormalization modules can not work with fragments. So to avoid complex rewriting for engine and denormalization we decided to merge fragments to avoid fields duplication - the most hard thing to support in engine. In this PR, we try to mimic graphql-py behavior or merging fields: - We remove complext 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
- Loading branch information
m.kindritskiy
committed
Jun 12, 2024
1 parent
593d052
commit 9dcf896
Showing
11 changed files
with
495 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.