defaultOptions do not work
See original GitHub issueI tried setting defaultOptions
like this:
export const apolloClient = new ApolloClient({
link,
cache,
connectToDevTools: true,
defaultOptions: {
watchQuery: {
fetchPolicy: 'cache-and-network'
},
query: {
fetchPolicy: 'cache-and-network'
}
}
})
and yet re-rendering of components does not trigger refetching, however manually setting fetchPolicy
option on a particular component does achieve the intended result
Issue Analytics
- State:
- Created 6 years ago
- Reactions:32
- Comments:43 (5 by maintainers)
Top Results From Across the Web
How do I correctly type the Apollo Client defaultOptions?
Basically, the behaviour/logic of query() is not supporting this strategy. So, they block it at typing level. React useQuery() hook. And if you' ......
Read more >class ApolloClient - Apollo GraphQL Docs
This is not the version of Apollo Client that you are using, ... To set defaultOptions when using the useQuery hook, make sure...
Read more >QueryClient | TanStack Query Docs
The logger this client uses to log debugging information, warnings and errors. If not set, console is the default logger. defaultOptions?: DefaultOptions.
Read more >CheckBox - defaultOptions not working - DevExpress Support
Good morning, after updating DevExtreme to 21.2.4 we are unable to use the defaultOptions of the dxCheckBox component.
Read more >The Effect of Default Options on Retirement Savings | NBER
For each of these decisions, there is usually a default option; for example, it could be that workers are not enrolled in the...
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 Free
Top 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
Okay, guys, I think the reason is you should provide all 3 properties together (watchQuery, query and mutate):
This code works
This code doesn’t affect to default options:
or…
@helios1138 @stefanholzapfel @sfilipov @hwillson please check it. It works for me.
You have to declare defaultOptions as a constant like this: