graphqlcache-server

1.0.9 • Public • Published

graphqlcache-server

About

graphqlcache-server module will let you cache graphql query data, if it finds the similar query it will return cached data.

Usage

import express from 'express'
import { graphqlExpress } from 'apollo-server-express';
import { graphql } from 'graphql';
const bodyParser = require('body-parser')

var graphqlcache = require('graphqlcache-server');

const app = express();
app.use(bodyParser.json()) /* must parse the body */

graphqlcache({
  engine: 'redis',    /* If you don't specify the redis engine,      */
  port: 6379,         /* the query results will be cached in memory. */
  host: 'localhost'
})


app.use(graphqlcache.intercept)

const options = {
   ttl: 86400 // Cache time out in seconds default is 60 seconds.
   cacheData: true /* Can turn on/off cached data response any time, default true */
}
app.use('/graphql', graphqlcache.sendIfCached(options), graphqlExpress({ schema }));

/graphqlcache-server/

    Package Sidebar

    Install

    npm i graphqlcache-server

    Weekly Downloads

    0

    Version

    1.0.9

    License

    MIT

    Unpacked Size

    90.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • aslam7