1.0.1 • Published 2 years ago

@magnicache/client v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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