onCacheHit
callback when query result is found in Apollo cache
#320
Labels
🪝 react hooks
Feature requests related to React hooks
The Problem
When using
cache-first
fetch policy I often require side-effects as result of querying data. TheonCompleted
callback generally addresses this problem, but only triggers when data is fetched from the server and not from cache. Currently, to address this problem, I need to implement a custom solution or change the fetch policy tocache-and-network
, which obviously means we no longer gain the benefit from caching the data.The Solution
Introduce an additional callback
onCacheHit
(Or something similar) that allows side-effects as a result of a query returning a result from cache.Why is it better?
No custom solutions required for detecting Apollo client cache hits. This really would fix the headaches I get working with apollo client.
The text was updated successfully, but these errors were encountered: