Closed fanckush closed 1 year ago
Hello, sorry for the late reply. At the moment this is outside villus scope since it does not make a relationship between queries and mutations.
However, it is possible for you to build a cache plugin that does this. Something along those lines:
import { definePlugin } from 'villus';
let myCache = {};
const cache = definePlugin({ afterQuery, useResult, operation }) => {
if (operation.cachePolicy === 'network-only') {
return;
}
if (operation.type === 'mutation') {
// delete entries from cache
return;
}
// add entries to cache ....
})
Of course, there is a little more involved than that, the main challenge is figuring out which mutations should clear which queries, it is up to you to figure out how such a connection be made. It can be based on a mutation name for example.
I spoke too soon. Having said that, there is a PR #184 that implements cache clearing for mutations that has the same tags as the queries. This is the connection challenge I mentioned.
If that is what you are looking for, then expect it to be out soon.
does Villus update the local cache after a mutation?
vue-apollo partially does
How should I approach this when using mutations in villus? Is there a way to update the stale cache after a successful mutation or maybe (as stated above) does Villus do this for me automatically?
Maybe i'm way off and this is outside the scope of villus. In this case is there a workaround? thank you!