-
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
Error when using pollInterval with fetchPolicy cache-and-network #3775
Comments
I'm a bit confused here as that error message only shows when the fetch policy is set to |
Can confirm this issue, tried adding I can probably create a reproduction, maybe there is some kind of sandbox/example repo for that? |
Hello. I was also under the impression
EDIT Ok. After a while we figured out what was causing our problem. I don't know if its your case, but it is indeed related to #3372. The problem in our case was that we used both server rendering and client rendering and the prop Therefore Apollo internally set Demo: this is the code, that is causing the trouble if (
this.disableNetworkFetches &&
(options.fetchPolicy === 'network-only' ||
options.fetchPolicy === 'cache-and-network')
) {
options = { ...options, fetchPolicy: 'cache-first' } as WatchQueryOptions;
} We tried to solve it by calling in child component componentDidMount() {
setTimeout(
() => { this.props.startPolling(45000); },
600,
);
} But we ran into an another issue, which is that even after the time of componentDidMount() {
setTimeout(
() => { this.setState({ pollInterval: 45000 }); },
600,
);
}
...
<Query query={query} pollInterval={this.state.pollInterval}>
.... The fact that Query components doesn't get remounted after the end of the delay should be documented somewhere, but that is a topic for another issue, in another place. I don't exactly know if this helps you, but I needed to clarify myself. Good luck! |
it helped me |
Closing as no reproduction was provided in one week. Feel free to reopen if you have a minimal reproduction. |
Hi @danilobuerger,
Sorry, but @OHUSAR did provide a Demo: https://github.com/OHUSAR/react-apollo-error-template. And the demo still shows what's going wrong. We are still having this issue. Can you take a look at the issue again, please? |
Hello @danilobuerger 👋, I just wanted to ask, if you've seen the comment above in the meantime. |
I faced with the same problem. Tried to specify both default options and fetchPolicy on query to 'cache-and-network' and even to 'network-only', and I'm still having an issue. |
This is definitely still an issue in In the interim there are two work-arounds:
|
@danilobuerger This is still an issue and the reproduction case provided in this thread illustrates it. Can you please re-open this issue? This link #3775 (comment) has a very clear reproduction and documentation of the issue. |
Hey guys, this worked for me:
|
When I'm trying to use fetchPolicy cache-and-network with pollInterval I have next error:
Uncaught Error: Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.
Could be related to this fix: #3372 Since now we reset fetchPolicy to cache-first internally when using cache-and-network.
Would be nice to fix this issue or at least update error message.
Workaround that I use for now:
The text was updated successfully, but these errors were encountered: