How to implement In memory cache from angular front with graphql Queries?

87 Views Asked by At

I have angular frontend application, we are fetching data with graphql queries using apollo client. We want to implements caching to fetch the data. Only first time we need to query the data and it should stored in cache , while calling the same next time the data should be returned from the cache. If any updates in data, it should call the query and should return the data.have written a graphql query to fetch the data. Need to know how to implement in memory cache.

1

There are 1 best solutions below

3
On

As I understand your question to keep your data up-to-date, consider regularly fetching from the server or setting up subscriptions on both the server and client. This allows you to send new events when data changes, enabling clients to subscribe and update their caches in real-time.

if you just need caching on the server with apollo, you can refer this documentation https://www.apollographql.com/docs/apollo-server/performance/cache-backends/