Cache evict from outside of the Apollo Context

I would like my application to automatically refresh some of my queries when they change on the backend. My solution is to setup an additional channel of communication via websockets. Via this websockets channel I’d be sending information what entities in my cache need to be refreshed. My initial plan was to parse those messages and evict specific entities from my cache, so that Apollo Graphql re-fetches them automatically.

My questions:

  1. Can I evict parts of my cache from outside of the Apollo Context?
  2. Is this a good approach to achieve what I have planned?
  3. If this is not a good approach, what would you suggest instead? Subscriptions seem to require too much additional work at least this is how it seems to me

This method is asynchronous, because it also refetches any of your active queries. To reset the cache without refetching active queries, use client. clearStore() instead of client. resetStore() .