Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-cache-lite

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-cache-lite

A lightweight cache implementation for Apollo Client.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

apollo-cache-lite

A lightweight cache implementation for Apollo Client.

Features

  • 🚀 Lightweight - Supports the most frequently used use-cases: SSR, extracting cache state, restoring cache state in browser, reading fragments from cache
  • 🔥 Fast - Read/write performance is the top priority to make your Apollo app faster
  • 🚨 Beta - Use it carefully, it's not production ready yet!

Getting started

  1. Install with npm or yarn:
npm i --save apollo-cache-lite

yarn add apollo-cache-lite
  1. Import in your app:
import { ApolloClient } from 'apollo-client';
import { ApolloCacheLite } from 'apollo-cache-lite';

const client = new ApolloClient({
    cache: new ApolloCacheLite(),
    // other apollo-client options…
});

Options

The ApolloCacheLite constructor takes an optional configuration object to customize the cache:

getIdFromObject

A function that takes a data object and returns a unique identifier.

import { ApolloCacheLite, getDefaultIdFromNode } from 'apollo-cache-lite';

const cache = new ApolloCacheLite({
    getIdFromObject(object) {
        switch (object.__typename) {
            case 'foo': return object.key; // use `key` as the primary key
            case 'bar': return `bar:${object.blah}`; // use `bar` prefix and `blah` as the primary key
            default: return getDefaultIdFromNode(object); // fall back to default handling
        }
    }
});

Keywords

FAQs

Package last updated on 20 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc