-
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
Infinite network requests with non-normalized objects #11879
Comments
Hi @oscar60310 👋 Thanks for opening this issue with a clear reproduction of what you're seeing! First, when I ran your reproduction, I noted that the
This is indeed what's happening, but for reasons I'll get into below, our two queries are "replacing the value" in an infinite loop, with no way to resolve the feud. First, here's the warning I saw: Can you confirm you see a similar warning? The warning notes that As you noted, when the The problem arises when I think a note in the docs advising against selecting non-overlapping fields on non-normalized objects would be helpful but would love any other ideas/suggestions you have here. Thanks! |
Hi @alessbell , thanks for the explanation!
Yes, I see the same warning. It makes me think that we might lose the benefit of the cache. In the worst case, each hook would send a single query. However, the consequence is much more critical than simply not using the cache; it could result in infinite requests being sent to our server. Is it possible to escape from the loop when we detect a cache issue? I noticed that if we don't have a value that changes with each request, there won't be an infinite loop, and the cache is not replaced (component1 and component2 both get the correct value). export const QUERY_DATA_1 = gql`
query foobar1 {
foobar {
id
# lastOnlineAt
nested {
value1
}
}
}
`; 2024-06-10.20-50-09.mp4 |
This sounds very similar to this issue, a fix was being worked on for that, but not sure what the status is for that and if it would fix this issue also. |
We're experiencing the same thing at Wiz. When the key field is missing accidentally for some object and the object returns two times in a short time with different fields this unexpected behavior happens. |
Issue Description
The issue is similar to #9450, but it involves an additional non-normalized object.
I have two components which query the same object with different properties:
Compoment1
Component2
I realized that we should define a merge function for the non-normalized object
foobar.nested
:Expected behaviour:
Before defining a merge function for it, I expected Apollo to log a warning and replace the value as described in the documentation.
Actual behaviour:
The two components send requests alternately and repeatedly.
2024-06-06.22-50-26.mp4
Link to Reproduction
https://github.com/oscar60310/apollo-issue-demo
Client code: https://github.com/oscar60310/apollo-issue-demo/blob/main/src/App.tsx
Server code: https://github.com/oscar60310/apollo-issue-demo/blob/main/server.js
Reproduction Steps
No response
@apollo/client
version3.10.4
The text was updated successfully, but these errors were encountered: