apollo icon indicating copy to clipboard operation
apollo copied to clipboard

fetchPolicy config not working for queries

Open widmerin opened this issue 3 years ago • 3 comments

Environment



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

widmerin avatar Jan 06 '23 13:01 widmerin

  • 1 Same issue and cannot see the Apollo dev tools either.

keithmifsud avatar Apr 12 '23 06:04 keithmifsud

I'm oddly having the opposite problem and no-cache is not respected and always hits the cache

ssyberg avatar Nov 16 '23 01:11 ssyberg

Just want to add I'm seeing this generally work for useQuery but not at all for useAsyncQuery

ssyberg avatar Nov 16 '23 16:11 ssyberg