@magnicache/client

1.0.1 • Public • Published

Magnicache/client

A lightweight client-side GraphQL caching solution that optimizes queries by atomizing complex queries and caching them individually.
MagniClient utilizes localStorage to cache query results across sessions.
Configurable cache size.


How to use @magnicache/client in your GraphQL client

  1. Install MagniCache Client.
npm i @magnicache/client
  1. Import MagniCache Client.
const MagniClient = require('@magnicache/client');
  1. Declare a new instance of MagniClient, optionally passing in a cache capacity(defaults to 40).
const magniClient = new MagniClient(maxSize);
  1. Invoke magniClient.query, passing in the query string and the graphql endpoint.
magniClient
  .query(
    `query {
    person(personID: 1) {
        name
        eyeColor
        height
    }
  }`,
    '/graphql'
  )
  .then((response) => {
    const queryData = response[0];
    const cacheStatus = response[1];
    // Handle the response data
  })
  .catch((err) => {
    // Handle errors
  });

Contributors

Ahmed Chami

Aria Soltankhah

Truman Miller

Yousuf Elkhoga

Package Sidebar

Install

npm i @magnicache/client

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

15.7 kB

Total Files

4

Last publish

Collaborators

  • achami64
  • trumanmiller
  • yousuf-e