Refactor custom field merge function processing. #5712
Merged
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.
Ever since implementing support for custom
merge
functions, I have been unsatisfied with theMergeOverrides
concept, especially because a mistake in the processing of overrides recently resulted in a fairly significant bug, fixed by commit 8c58be5.Instead of tracking
MergeOverrides
separately from the fields processed byprocessSelectionSet
andprocessFieldValue
(which is not only error-prone but also complicates the return values of those methods), we can embed the necessaryFieldNode
and__typename
information within the field data returned byprocessSelectionSet
, using recognizableFieldValueToBeMerged
objects, which are safely removed byPolicies#applyMerges
before the fully processed fields are written into theEntityStore
(which knows nothing about custommerge
functions orFieldValueToBeMerged
objects).One small benefit of this refactoring is that we can call
store.getFieldValue(dataId, name)
instead ofstore.get(dataId)
inPolicies#applyMerges
, which brings us a little closer to eliminatingEntityStore#get
once and for all.