@saltyaom/gql-local-cache

v1.1.9
Local Storage Cache Plugin for @saltyaom/gql
graphql graphql client

@saltyaom/gql-local-cache

Local Storage Cache Plugin for @saltyaom/gql

Example Usage

import gql, { client } from '@saltyaom/gql'
import localCache from '@saltyaom/gql-local-cache'

client.config(
  'https://api.opener.studio/graphql', 
  {
    plugins: [localCache()]
  }
)

gql(
  `query GetHentaiById($id: Int!) {
    getHentaiById(id: $id) {
      success
      data {
        title {
          display
          japanese
        }
      }
    }
  }`,
  {
    variables: {
      id: 177013
    }
  }
).then((data) => {
  console.log(data)
})

Custom Config

You can pass custom config to localCache()

Available config:

  • ttl
    • How long should the cache live in seconds.
    • default: 86400 seconds (1 days)
npm i @saltyaom/[email protected]

Metadata

  • MIT
  • Whatever
  • saltyaom
  • released 4/24/2022

Downloads

Maintainers