Apollo Client 3 evict query result - doesn't work?

Viewed 1972

Using Apollo Client 3 and eed to remove all the results of a query regardless of the arguments. Tried like this;

       cache.evict({
          id: "ROOT_QUERY",
          fieldName: "countries"
        });

        cache.gc();

However nothing removed from cache, __APOLLO_CLIENT__.cache.data still has all the result in the cache. I can remove a single Country object on the other hand.

You can see it here sandbox

1 Answers

Simple adding broadcast: false parameter solved the problem;

               cache.evict({
                  id: 'ROOT_QUERY',
                  fieldName: 'countries',
                  broadcast: false,
                });
                cache.gc();
Related