Zero-dependency helper for updating Apollo Client's cache after GraphQL mutations. Version 0.1.3, under heavy development. Automatically updates multiple cached queries (including those with filtered variables) after add/remove/list operations, reducing boilerplate compared to manual cache writes. Works with Apollo Client's data proxy to handle complex scenarios like adding/removing items from lists, updating filtered lists, and maintaining cross-query consistency. Supports React, Vue, and React Native. Note: early stage, breaking changes likely.
npm install apollo-cache-updaterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use ApolloCacheUpdater to automatically update multiple queries in Apollo cache after a mutation, with variable filtering.
Pin to exact version and test upgrades carefully.
Use (proxy, { data }) => ApolloCacheUpdater({ proxy, ... }) from mutation's update handler.Pass the imported gql template literal result, e.g., [GET_ARTICLES].
Include all variables from the query's cache key that need to match.
Consider using apollo-cache-updater with plain JavaScript or create custom type declarations.
Change import to: import ApolloCacheUpdater from 'apollo-cache-updater'
Ensure proxy is the first argument of the update function: update: (proxy, { data }) => ...Pass array of queries imported from .graphql or gql template: [GET_ARTICLES]
Check that searchVariables includes all variables from the target query, not just a subset.
No dependency data recorded yet.