Error when using pollInterval with fetchPolicy cache-and-network
See original GitHub issueWhen 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: https://github.com/apollographql/apollo-client/pull/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:
...
componentDidMount() {
setTimeout(() => {
this.props.data.startPolling(1000);
}, 0)
}
...
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
When your component renders, useQuery returns an object from Apollo Client that contains loading , error , and data properties you can use...
Read more >useQuery pollInterval with cache-and-network doesn't stop to ...
I've made the issue here in apollo-client repository. It works well with other fetchPolicy options but it doens't work correctly with ...
Read more >client.watchQuery cannot be called with fetchPolicy set to ...
I get this error on v3.4.17 and v3.4.0 which were mentioned in earlier posts. I think the issue is caused by @apollo/react-hooks.
Read more >Interfaces: ApolloQuery - Apollo Elements
When someone chooses cache-and-network or network-only as their initial FetchPolicy, they often do not want future cache updates to trigger unconditional ...
Read more >Graphql Client with React & Apollo | by Héla Ben Khalfallah
pollInterval : 500, // fetchPolicy: 'cache-and-network' }); if (loading) return <p>Loading...</p>; if (error) return <p>Error :(</p>;
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
Closing as no reproduction was provided in one week. Feel free to reopen if you have a minimal reproduction.