fix(graphcache): Fix defer field state becoming sticky and affecting future fields #3167
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.
Resolves #3161
Note: This will need a rebase after #3165 is merged and should be merged on top.
Summary
A rather old regression would cause
@defer
directives to manipulate thedeferRef
state and then become “sticky”, meaning that all future fields would also be considered deferred.Instead, we need to make sure that this field resets properly and that the state returns to normal.
On a side-note, I tried to convert
makeSelectionIterator
to a generator function, since this would make it more elegant, but an initial rough implementation decreased overall cache read/write performance by 15–20%, so we'll have to investigate whether there's more we can do here. In general, traversal is the most expensive part of the cache operations, so if we can instead make it faster we'd profit from that quite a lot.Set of changes
makeSelectionIterator
to resetdeferRef
makeSelectionIterator