apollo icon indicating copy to clipboard operation
apollo copied to clipboard

fetchPolicy no-cache not working

Open mg98 opened this issue 5 years ago • 6 comments
trafficstars

Describe the bug The fetchPolicy 'no-cache'is supposed to disable the default behavior for GraphQL queries to take the cached response of the query and thus save on network requests. I always wanted this behavior but never got it working in my app. Now I have set up a fresh project just for demo and it is not working here either.

To Reproduce Steps to reproduce the behavior:

Try to send the same graphql query two or more times and notice it will only send one network request.

I have setup a demo project for this: https://github.com/mg98/apollo-cache-not-working I created it with the Vue CLI and vue add apollo with pre setup configuration. Follow the readme to start the app. There will be a text explaining you how to test the behavior.

Expected behavior Always send a network request, because I globally set fetchPolicy to 'no-cache'.

Versions vue: 2.6.11 vue-apollo: 3.0.0.beta.11, I can also verify for 3.0.3

mg98 avatar May 30 '20 12:05 mg98

Actually seeing a similar issue when setting no-cache for individual queries. When making a request the browser freezes while storing data in cache :(

vlodko avatar Feb 02 '21 12:02 vlodko

Looks like I have something similar.

If I setup fetch-policy to no-cache in createApolloClient, the cache still will work. It won't send the second query.

But if I set it for individual request, it works:

 const response = await this.$apollo.query({
        query: getForeignCitizens,
        variables: this.filters,
        fetchPolicy: 'no-cache'
      })

victor-ponamariov avatar May 19 '21 23:05 victor-ponamariov

This is so serious bug that I had to switch to a pure HTTP request. :(

hipertracker avatar Mar 12 '22 01:03 hipertracker

any news on that?

romain130492 avatar Oct 27 '22 05:10 romain130492

Any news on this?

carolinecblaker avatar Jan 08 '24 23:01 carolinecblaker

I can't reproduce on my side. Please provide a runnable reproduction.

Akryum avatar Jan 15 '24 09:01 Akryum