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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bundl-cache

v1.0.6

Published

bunDL is an intuitive, skinny GraphQL interceptor, that checks for cached data, handles mutations with PouchDB, and only sends modified or non-cached queries to the server. The returned data is then cached for future requests.

Downloads

5

Readme

bundl-cache

bundl-cache is a client-side GraphQL caching solution, optimized for the Bun runtime. Our product is designed to intercept GraphQL queries, parse through relevant information from the AST, and generate unique cache key/value pairs to accomodate for an array of query types all within the browser. BunDL is most optimal when utilizing pouchDB and couchDB. The offline synchronization between the two databases allowed us to further reduce requests to the server and provide a seamless experience for the user in terms of performance speeds.

Installation

Within your terminal, download bundl-cache with 'bun install bundl-cache'

Implementation

  1. Import BunDL from 'bundl-cache'
  2. Create a new instance of 'bundl-cache'
  3. Set configurations based on your caching needs
  4. Replace any fetch requests with 'bunDL.query'

Example:

If a user queries the following code below...

const query = `query {
  company (id: 123) {
    name
    city
    state
    department {
      name
    }
  }
}`;

A typical fetch request may look like this:

fetch('/graphql', {
  method: 'POST',
  body: JSON.stringify({ query }),
  headers: { 'Content-Type': 'application/json' },
});

With bunDL your fetch request would now look like the following:

const BunDL = new BunDL();

BunDL.query('/graphQL', query).then(/* use parsed response */);

Before creating a new instance of BunDL, you may also pass in specific configurations. However, this feature is currently in beta and may exhibit unintended bugs. We encourage users to stick with default configurations for the time being.

Currently, the default configurations are:

const defaultConfig = {
  cacheMetadata: false,
  cacheVariables: true,
  requireArguments: true,
};

Setting 'cacheMetadata' to true will reconfigure bunDL to store additional information about the query (This may decrease performance speeds) Setting 'cacheVariables' to false will reconfigure bunDL to cache queries without variables Setting 'requireArguments' to false will reconfigure bunDL to cache queries without arguments.

To set your own configurations, initialize an object with any or all of the default configurations and change the boolean to your desired option.

Usage Notes

  • bunDL is around 94% faster than fetching the same data without caching over a network request. However, our current limitations lies within the granularity of our caching solutions. The bunDL developers are always looking to improve our product, and any support/contributions from the open source community is always welcomed.

  • bunDL can only cache 1-2-depth queries with arguments/variables

  • Any mutated queries will invalidate the entire cache

  • Deeply nested (3-depth+) queries will not be cached

  • Partial queries works at the single depth level and inconsistently works on the 2-depth level