Shopify

Apollo Cache is Your Friend, If You Get To Know It - Shopify

Nov 9, 2022
Apollo Cache is Your Friend, If You Get To Know It - Shopify
SummaryAI, from the source post

This post details the internal workings of the Apollo client's InMemoryCache, focusing on data fetching policies, normalization strategies (object breakdown, unique cache identifiers using `__typename` and `id` or custom `keyFields`, and flattening into a hash map), and the lifecycle of cached objects. It explains automatic cache updates for single entities and collections when mutations return complete data, and outlines scenarios requiring manual intervention (update functions or refetches) for UI consistency, such as when query responses don't directly map to cache changes, incomplete data is returned, list order changes, or items are added/removed without returning the full list. It also revisits an initial query example to illustrate a cache misuse scenario.