-
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
apollo-client not working as expected for network-only
cache policy, duplicate requests noticed
#6313
Comments
@mhuconcern Can you provide a small runnable reproduction that shows this? Thanks! |
@mhuconcern Actually, one more thing to mention here. Using |
@hwillson I probably should word it correctly but yes we don't use Apollo link dedup seperately :) I thought it was the offending library |
network-only
cache policy, duplicate requests noticednetwork-only
cache policy, duplicate requests noticed
network-only
cache policy, duplicate requests noticednetwork-only
cache policy, duplicate requests noticed
I am seeing this as well. The change happened in
I will work on unraveling my project a bit and try to create a reproduction. |
For what it's worth, I am also getting "No more mocked responses" error for queries and mutations that do not have a |
I can confirm that this is happening in our application on I am sorry I cannot provide a minimum reproduction, but for what it's worth we are using |
Are we talking about 'network-only' and 'no-cache' fetching from cache and not executing server requests, right? If so, I have the same problem for 'network-only' as well as for 'no-cache' with Apollo Client v3.0.0-rc.4.
If called 3 times, only 1 network call in Chrome's Network tab (and only 1 server log). Only creating new |
There is something I don't understand from the docs:
What is meant by "initial data"? I tried to browse through the doc for its meaning, but it is not clarified. |
@thojanssens #6353 should help explain what you're seeing. |
It's hard for me to create a runnable; I'd insert I'll get back to you if I find a few hours free to play with some public GraphQL API and an environment without react deps. |
Thanks @thojanssens - is the cache empty when you call |
@hwillson When I tested I was refreshing the page, so the cache was empty as it is in memory. We might use Apollo client when our application will grow; for the moment I will go for simple fetch requests. I'm no longer able to comment on this issue. Thank you |
I've been digging through open issues a bit trying to find something similar to what I've been experiencing, and I'd like to suggest that this may be a duplicate of #6301. The reproduction linked and the fix suggested there may be helpful. |
In my case I noticed second http request was being made with empty variables when I use useEffect(() => {
if (!loading && data?.events.list.length === 0) refetch();
}, [loading, data]);
useEffect(() => {
return () => {
client.cache.modify({
id: 'EventPagination:events#allEvents',
fields: {
cursor: () => null,
hasMore: () => true,
list: () => [],
},
});
};
}, []); |
minimal reproduction here: codesandbox Intended outcome: Actual outcome: How to reproduce the issue: |
I have this issue when using
Any solution to this? |
When i use fetchMore and don't set fetchPolicy to |
running into the same issue as @kfazinic — cache-first is the only option that will render the correct data. |
Any update from this issue? I am also experiencing duplicate network requests using useQuery hook of @Apollo/client. Thanks |
Sorry guys, I'm upgrading my project from v2 to v3. I'm trying to figure out why is it making duplicate requests. Correct me if I'm wrong team, I solved my the problem, in my case, by providing both fetchPolicy and nextFetchPolicy in useQuery hook? For example, fetchPolicy: "cache-and-network" and nextFetchPolicy: "cache-first". |
@mhuconcern 👋 We know this is a pretty old issue, but the team is trying to determining if this is still a problem. Could you try updating to the latest version of Apollo Client and letting us know? |
@jpvajda We have upgraded to the latest version, We don't notice this anymore. Thank you so much ill close the ticket |
@mhuconcern thank you for confirming! |
Intended outcome:
Network tab doesn't show duplicate query requests
Actual outcome:
Noticed the query being requested for twice
How to reproduce the issue:
Versions
System:
OS: macOS High Sierra 10.13.6
Binaries:
Node: 12.9.1 - /usr/local/bin/node
npm: 6.10.3 - /usr/local/bin/npm
Browsers:
Chrome: 84.0.4143.2
Firefox: 75.0
Safari: 13.1
npmGlobalPackages:
apollo: 3.0.0-beta.45
The text was updated successfully, but these errors were encountered: