Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate options.invalidate function in favor of local variables. #5883

Merged

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Jan 30, 2020

Every use case for options.invalidate (introduced in #5667) can be handled more precisely using
local 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 calling options.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.

Every use case for options.invalidate can be handled more precisely using
local variables, because 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.

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.
@benjamn benjamn added this to the Release 3.0 milestone Jan 30, 2020
@benjamn benjamn requested a review from hwillson January 30, 2020 18:05
@benjamn benjamn self-assigned this Jan 30, 2020
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes a lot of sense, and looks great @benjamn!

@benjamn benjamn merged commit 2a0ffdf into master Jan 30, 2020
@benjamn benjamn deleted the eliminate-options.invalidate-in-favor-of-local-variables branch January 30, 2020 18:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants