I am using apollo-server-caching in apollo server, on mutation requests, cache is not getting updated and I am getting old cached data on refetch of a query after mutation in frontend
Can anyone guide me, how I can handle cache update on mutation in apollo server?
Below is my code implementation of server cache
export class MemoryCache implements KeyValueCache {
cache: { [key: string]: string } = {};
async get(key: string): Promise<string> {
console.log(`get ${key}`);
const value = this.cache[key];
return value;
}
async set(key: string, value: string): Promise<void> {
console.log(`set ${key}`);
this.cache[key] = value;
}
async delete(key: string): Promise<void> {
console.log(`delete: ${key}`);
delete this.cache[key];
}
async reset() {
this.cache = {};
}
}