fetchPolicy config not working for queries
Environment
- Operating System:
Darwin - Node Version:
v16.18.0 - Nuxt Version:
3.0.0 - Nitro Version:
1.0.0 - Package Manager:
[email protected] - Builder:
vite - User Config:
runtimeConfig,css,vite,components,build,modules,proxy,serverMiddleware,apollo,alias - Runtime Modules:
@nuxtjs/[email protected],[email protected],@formkit/[email protected],@pinia/[email protected],@nuxtjs/[email protected],@nuxtjs/[email protected] - Build Modules:
-
Describe the bug
I tried to change the fetch policy for apollo in the nuxt.config.ts to cache-first
defaultOptions: {
query: {
fetchPolicy: 'cache-first',
},
...
}
This setting has no effect on the queries, which are always executed with no-cache
Expected behaviour
Queries should use fetch Policy from defaultOptions.
Reproduction
I use [email protected] and @nuxtjs/[email protected]
Nuxt config:
apollo: {
defaultOptions: {
query: {
fetchPolicy: 'cache-first',
},
},
...
}
Query
const { data } = await useAsyncQuery(query)
Additional context
In the https://github.com/nuxt-modules/apollo/blob/v5/src/runtime/composables.ts#L51 the queries get set to no-cache, how can I overwrite this? Is there a way that I can use apollo cache for queries?
Logs
No response
- 1 Same issue and cannot see the Apollo dev tools either.
I'm oddly having the opposite problem and no-cache is not respected and always hits the cache
Just want to add I'm seeing this generally work for useQuery but not at all for useAsyncQuery