nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
929 stars 194 forks source link

Evict({}) not working #591

Open cory-mosey opened 5 months ago

cory-mosey commented 5 months ago

Environment

Describe the bug

Page 1: Uses the useQuery function with the 'fetch-policy' of 'cache-first' to get a list of items. For example, { id: 1, __typename: 'Item' }

Page 2: On a seperate page I have a DeleteItem mutation with an update calling evict: await deleteItem({}, { update: (cache, { data }) => { const apollo = useApollo(); apollo.clients.default.cache.evict({ id: apollo.clients.default.cache.identify({ id: 1, __typename: 'Item' }) }); apollo.clients.default.cache.gc(); } });

Expected behaviour

Expecting to see the Item removed from cache in all instances.

Reproduction

No response

Additional context

No response

Logs

No response

cory-mosey commented 5 months ago

Just to add 'Item' is also in a nested query.

And I'm getting a console error with: 'An error occured! For more details...' which takes me to the following page: https://www.apollographql.com/docs/react/errors/#%7B%22version%22%3A%223.8.1%22%2C%22message%22%3A12%2C%22args%22%3A%5B%5D%7D

Yet all my queries have IDs?