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

Improvements to options.nextFetchPolicy. #6893

Merged
merged 4 commits into from
Aug 25, 2020

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Aug 25, 2020

When we introduced options.nextFetchPolicy in #6712, it could only be a string, so you needed to have some way of also knowing the current fetchPolicy, in order to be sure nextFetchPolicy was appropriate.

Since there has been some interest in setting defaultOptions.watchQuery.nextFetchPolicy as a global option (e.g. #6712 (comment)), we want to be sure that's possible without making blind guesses about the current options.fetchPolicy. To that end, nextFetchPolicy can now be a function that takes the current FetchPolicy (which defaults to cache-first) and returns a new FetchPolicy based on the current one (possibly leaving it unchanged). For example, this allows you to transition from cache-and-network or network-only to cache-first, but leave other policies the same.

The other commits in this PR use nextFetchPolicy to fix some bugs in our polling implementation, and in ObservableQuery#{refetch,setVariables}. With any luck, these changes will help with #6858.

Although options.nextFetchPolicy will usually be a string, allowing it to
be a function that takes the current FetchPolicy and returns a new (or the
same) FetchPolicy allows for more precision, which is important when
you're configuring defaultOptions.watchQuery.nextFetchPolicy, since you
probably want to alter only some fetch policies and leave the others
unmodified.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant