[fix] [#149] do not merge/extract fragment fields into node fields #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If there is no such field in node, leave field in fragment
There was a part of algo in nodes merging which will extract fields from fragment if same fields exist in node - this is to prevent same field to be resolved multiple times. The simplest example is
{ user { id ... on User { id } } }
would become{ user { id } }
soid
field will be resolved only once.But previous algo (before this fix) would merge eagerly, so even if no field exits in node, algo will try to eliminate fragment at all, for example
{ user { ... on User { id } } }
would become{ user { id } }
- fragment is eliminated.This behavior breaks union queries and we must not touch union fragment, since this breaks unions. This fix tells algo to merge less eagerly, thas is - if fragment field not exist in node, we leave this field in fragment since there is nothing to optimize, no fields duplication will occur.
Note that although we do not merge fragment field to node fields, we still merge fields for the very same fragment field (see
_merge_link
).Here are the rules: