npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@conpagoaus/apollo-cache-helpers

v0.2.5

Published

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/conpagoaus/apollo-cache-helpers/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/conpagoaus/apollo-cache-helpers/tree/main) Helpers to make working with @apollo/client cach

Readme

apollo-cache-helpers

CircleCI Helpers to make working with @apollo/client cache easier

Setup

npm:

npm install @conpagoaus/apollo-cache-helpers

yarn:

yarn add @conpagoaus/apollo-cache-helpers

Usage

Addition to cache

This covers a use case when we perform a mutation which adds a entry to a list and would like to see new entry without refetching original query: Adding todo without refetching GetTodos query.

As Apollo cannot determine which query it needs to inject data to, we need to help it a bit. For this we have two functions appendToCache and prependToCache Example usage:

appendToCache({
      cache: client.cache,
      query: TEST_LIST_QUERY,
      data: {
        id: "2",
        name: "Jane",
      },
    });

This call will append a new item to the end of first selection set of specified query. prependToCache does the same but adds a new item to the beginning of the list.

Limitations:

  • These functions only work with queries with single selection set. PR's are welcome to include support for multiple.
  • Query must return selection set with array type.

Removal from cache

Cache removal is performed using removeFromCache function. We also(unless specified otherwise) will remove normalized values of removed item from cache. Keep this in mind for item being used in multiple queries. Example usage:

removeFromCache({
      cache: client.cache,
      query: TEST_LIST_QUERY,
      data: {
        id: testClients[0].id,
      },
    });

This call will remove first client from query result set as well as remove first client from normalized cache. If we want to avoid removing from normalized cache we can specify removeNormalized: false option allows to only remove from query results without removing from normalized cache.

Options:

  • removeNormalized - enabled by default. Determines if removeFromCache should also remove item from apollo normalized cache.

Limitations:

  • The removal function only work with queries with single selection set. PR's are welcome to include support for multiple.
  • Query must return selection set with array type.

Any other updates

For any other updates updateCache function is provided with immer support - no need to worry about not mutating things. We can change what is needed and immer will handle making an immutable change. Example usage:

updateCache({
      cache: client.cache,
      query: TEST_QUERY,
      variables: { id: "1" },
      updateFn: (draft) => {
        draft.client.name = "test";
      }
});

This function call will update client name in result set of the query specified. Make sure to pass all the variables which were used in original query - otherwise Apollo won't be able to match queries. In that scenario and any other mismatches library will print console warning No cached data found.

Options:

  • inputOptions.debug - disable by default. Enables debugging logging to help identify what is being written to cache.
  • inputOptions.logger - console by default. Logger can be redirected to any other logger supporting ILogger type.