-
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
FetchPolicy seems to be moderately broken - summary #3452
Comments
Thanks for putting this list together @OllieJennings! I've been working through all outstanding
Help is 💯% always welcome! If you're able to chip in by reviewing these issues and adding your comments, helping with reproductions, or better yet, working on PR's, that would be awesome! |
Using Specifically, I end up with:
when using // package.json
"apollo-cache-inmemory": "1.2.1",
"apollo-client": "2.3.1",
"apollo-codegen": "0.19.1",
"apollo-link": "1.2.2",
"apollo-link-error": "1.0.9",
"apollo-link-http": "1.5.4",
"react-apollo": "2.1.4" Here is a reproduction, showing how the data is missing: It also demonstrates different results when Related: Using |
I am not sure about this one it is just my quick observation but it seems that when using |
meet the same issue |
I also had an issue with apollo-client being used in conjunction with apollo-link-state. If I do not explicitly specify a 'no-cache' fetchPolicy on the for local state, I would get stale data on page change despite proper updates on the component before page change. |
|
same here::
|
Has anyone found a decent workaround for disabling the auto caching? |
We added a resolver that is a "cache buster" so that we send unique queries every time since the arguments are different given a unique id (using the query Document($documentId: String!, $uniqueId: String) {
# Original query
document(ID: $documentId) { ... }
# This resolver just returns true and is used so that our query always has a unique arg
cacheBuster(uniqueID: $uniqueId)
} import uuid from 'uuid';
...
<Query query={documentQuery} variables={{ documentId: "1234", uniqueId: uuid.v4() }} |
@kristiehowboutdat wouldn't this also fill up your cache unnecessarily? Given the cache isn't a proper cache (with an LRU) this will cause your app's memory demand to increase. |
Yeah @jync, there are a couple of downsides, including that. It's a workaround, not a solution 😞 For our app we cannot have cached values, and using Would welcome suggestions on how to avoid filling the cache at all or clearing it. Last time I looked at the docs (1-2 months ago), I didn't find a good way to programmatically clear the cache. |
When I don't set the defaultOptions for ApolloClient, it uses the 'cache-first' as expected, but when I set it explicit with the defaultOptions it seems to use 'network-only' even If I have it set to 'cache-first' example can be found here https://codesandbox.io/s/jjn4pnnz7v |
Any workaround for this? Seems like apollo client is not usable because of this issue! |
Related Issue: apollographql/apollo-link-state#272 |
@fbartho In a project in which I dont use |
Hi all - I'll be tackling this issue in chunks, since there is a lot covered here. First up is dealing with any outstanding |
Thanks @hwillson for your fix. I tested the I tried to debug my example and it looks like the query can resolve the data, but immediately removes it again.
Anyone else experiencing this on |
@michaelknoch Can you try the recently released |
the error still occurs, but only once in 5 app launches @hwillson |
I'm facing the same random issue as @michaelknoch. Not sure, but I found that if I delay the response from the server it will never return To test I'm using bluebird on the server with something like... require('bluebird').delay(1000, { foo: 'bar' }) |
@michaelknoch @hwillson i am getting the same issue as well. I am using 2.4.0. Occasionally it will work as expected, when it doesn't I can see the query keeps running periodically. The second and every query after that is returning an empty object. |
I'm having an issue with the optimistic response. When |
Using this approach:
causes Console warning:
|
any progress on this? Im still running into the weird issue mentioned on August 9 |
Hey @hwillson I am seeing the same issue as @SergeyVolynkin - your suggested fix does not work when importing This is really frustrating ... if Apollo caching doesn't work, it really reduces the performance of Does caching work if I setup the ApolloClient myself, i.e. do not use apollo boost? |
We use apollo-client 2.4.1 and experienced issues with no-cache: From what we could gather, for no apparent reason, once every few times (less than 10 in our case) the Query component will trigger twice when fetchPolicy is set to no-cache. The first invocation will have the data, the second invocation will not. We have replaced all our "no-cache" policies with "network-only" and will continue monitoring. |
The react I have fixed your example here https://codesandbox.io/s/68q5p5vow |
I am using withApollo() and no-cache does not work for me either. I ended up with a workaround using client.resetStore() directly after a mutation to empty the cache. |
I was able to reproduce it within the original apollo codesandbox example by setting the fetchPolicy to "no-cache" https://codesandbox.io/s/k9y4v0wlov. Due to some experiments I think this issue is a bug in react-apollo. The watchquery itself seems to work as expected, but maybe im wrong |
@thanpolas #4573 fixes that issue. |
Avoid updating (and later invalidating) cache watches when fetchPolicy is no-cache. Part of #3452.
It appears #4352 introduced a new bug related to fetch-policy: 'no-cache'. The original QueryManager code would would call this.dataStore.getCache().read() inside getCurrentQueryResult(), which would throw an exception and |
Since a lot of these issues have been fixed, let's open issues related to specific problems instead of one bulk one! Thank you! |
I have a similar problem. EX)
[process] [reason]
[logic1]
[logic2]
[logic3]
[logic4]
[Method currently being considered] I am thinking of a method of separating components only in the search box and fetching components whenever they are called... |
Like the title states,
fetchPolicy
inapollo-client
seems to becompletelymoderately broken.I thought it would be a good idea to round up all of the issues in a central place:
no-cache
:cache-and-network
:cache-only
:network-only
:Misc:
Issues related in React-Apollo repo:
network-only
:cache-and-network
:Personally l am experiencing all of the issues above in the latest version of apollo-client. It would be good to get these properly addressed as they are a pretty important part of apollo.
If anyone else has any more issues (closed or open) that can be linked into this, just comment below with it.
@evans and @jbaxleyiii Can we get this put as quite a high priority on the apollo-client Roadmap, if help is need, l can also look into these on the weekend
Version
Issue Labels
The text was updated successfully, but these errors were encountered: