Eliminate options.invalidate function in favor of local variables. #5883
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.
Every use case for
options.invalidate
(introduced in #5667) can be handled more precisely usinglocal variables (introduced in #5799).
There's no reason to invalidate every query that consumed the field when you can invalidate just the queries that depended on specific local variables. In the case where a field's
read
function only consumes a single local variable, the effect of updating that variable is the same as callingoptions.invalidate
.Storing local variables in the
options.storage
object is still often a good idea, because that way they're scoped to the field, rather than being shared global variables. You can see an example of that in the tests that I updated in this PR.This change should also make it easier to explain field invalidation in our documentation, because we can just build on the explanation of local variables, rather than introducing a new but redundant concept.