Skip to content

Changes to context cause refetches in useQuery #11835

Closed
@jerelmiller

Description

@jerelmiller

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions