I have a few mutations that should trigger some refetchQueries, but I need those queries to have a fetchPolicy other than the default.
Is there a way to set fetchPolicy globally instead of per query? So to avoid setting fetchPolicy on each query.
It is now possible!
const defaultOptions = {
watchQuery: {
fetchPolicy: 'cache-and-network',
errorPolicy: 'ignore',
},
query: {
fetchPolicy: 'network-only',
errorPolicy: 'all',
},
mutate: {
errorPolicy: 'all'
}
}
const client = new ApolloClient({
link,
cache,
defaultOptions,
})
See documentation: Apollo Client