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

Changes to context cause refetches in useQuery #11835

Open
jerelmiller opened this issue May 6, 2024 · 0 comments
Open

Changes to context cause refetches in useQuery #11835

jerelmiller opened this issue May 6, 2024 · 0 comments
Labels

Comments

@jerelmiller
Copy link
Member

Issue Description

Changes to context can cause new network requests when updated between renders. This is due to the fact that we do a deep equality check on options and if they change, execute a reobserve. In many cases, this works ok as the applied options should just cause the client to read from the cache again, but when used with a fetchPolicy like no-cache, this can cause new refetches. This is especially problematic if you want to use AbortController to handle cancelling previous fetches.

We should also consider expanding this to other options as well. For example, a change to errorPolicy should not cause a refetch but rather should be applied to the next fetch. Suspense hooks already have this behavior built-in.

We should also consider adding the ability to revert the behavior back to its current form where changes to context would cause refetches in case there are users that currently rely on this.

Link to Reproduction

https://discord.com/channels/1022972389463687228/1235943877765238847/1235943877765238847

Reproduction Steps

No response

@apollo/client version

3.10.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant