vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6.02k stars 523 forks source link

fetchPolicy no-cache not working #992

Open mg98 opened 4 years ago

mg98 commented 4 years ago

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

vlodko commented 3 years ago

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

victor-ponamariov commented 3 years ago

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'
      })
hipertracker commented 2 years ago

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

romain130492 commented 2 years ago

any news on that?

carolinecblaker commented 9 months ago

Any news on this?

Akryum commented 9 months ago

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