Stephen Lautier
Stephen Lautier

Reputation: 3365

Apollo GQL - Clear cache for one type only

I would like to be able to clear the cache of only one specified type

e.g. if I have Authors and Books I would like to only clear cache for Authors

I'm using @apollo/client": "^3.2.5" (latest)

Just additional note, shouldn't matter much but I'm using it with Angular.

apollo.client.clearStore(); // this clears all store

Tried to use the apollo.client.cache.writeQuery, however no luck yet

Remove by the __typename would be ideal or something related

Upvotes: 1

Views: 595

Answers (1)

Stephen Lautier
Stephen Lautier

Reputation: 3365

Using the v3 it seems by using the evict api is doing what I needed

this.apollo.client.cache.evict({
    fieldName: "authors",
});

Upvotes: 2

Related Questions