-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Deduplication issue with react #12216
Comments
Related issues: Was this useful? Use the thumbs up or thumbs down reaction to give feedback. |
Hey @canda 👋 If you check your console, you'll see a warning about this which takes you to this error link which reads:
This issue here is that the cache doesn't know how to merge these objects together since they are non-normalized. The default behavior is to completely replace non-normalized objects. Because of this, whatever request completes second will overwrite the results from the first request. That causes data to disappear, so the first query thinks it needs to refetch again to fulfill the result of the query. You can fix this either by querying for |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Issue Description
Hey there!
I'd like to ask for a little help here 🙏.
I am seeing duplicate network requests on my React application.
I was able to reproduce this issue on a simple example with two
useQuery
hooks with almost identical queries. One asks for thedetails
in theroadster
object, the other one asks for thename
in theroadster
object.The result:
4 network requests are triggered:
ExampleQuery2
(fine)IntrospectionQuery
(fine I guess)ExampleQuery1
(fine)ExampleQuery2
(duplicated ❌)Link to Reproduction
https://codesandbox.io/p/sandbox/apollo-react-deduplication-bug-cmcv2h?file=%2Fsrc%2FApp.tsx%3A44%2C53-45%2C32
Reproduction Steps
Go to https://cmcv2h.csb.app/ and open devtools.
Refresh the page, and you should see the repeated queries.
@apollo/client
version3.12.2
The text was updated successfully, but these errors were encountered: