Apollo-client: delete cache by operation name?

Created on 7 Jan 2020  路  3Comments  路  Source: apollographql/apollo-client

query pageQueryProducts($page: Int, $perPage: Int, $filter: ProductFilter) { products(page: $page, perPage: $perPage, filter: $filter) { count items { id productName } pageInfo { perPage currentPage } } }
Is there any way to delete cache by "pageQueryProducts"?

idea 鈦夛笍 question 馃尋 has-workaround

Most helpful comment

Nice, it works for me. I will upgrade to 3.x

All 3 comments

Assuming you're using @apollo/[email protected], you should be able to do this:

cache.evict("ROOT_QUERY", "products")

If the pageQueryProducts query had more than one root field, you could call cache.evict for each field. Does that help?

Nice, it works for me. I will upgrade to 3.x

This works but does not trigger a re-render if the query is displayed. Any idea how to do it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dispix picture dispix  路  3Comments

canercandan picture canercandan  路  3Comments

stubailo picture stubailo  路  3Comments

rafgraph picture rafgraph  路  3Comments

treecy picture treecy  路  3Comments