@magnicache/server

1.0.9 • Public • Published

Magnicache/server

@magnicache/server is a lightweight GraphQL caching solution.

Imported as a package from npm, @magnicache/server can be inserted into the middleware chain for a GraphQL endpoint to intercept GraphQL requests and scan the cache for previously executed queries.

Queries present in the cache will return the cached result to the client, improving response speeds and overall GraphQL performance.


How to use @magnicache/server in your GraphQL api

  1. Install MagniCache Server.
npm i @magnicache/server
  1. Import MagniCache.
const MagniCache = require('@magnicache/server');
  1. Declare a new instance of MagniCache, passing in your GraphQL schema.
const magnicache = new MagniCache(schema);
  1. Insert magnicache.query into the middleware chain for your '/graphql' route.

    • Ensure all request bodies are parsed
app.use(express.json());

app.use('/graphql', magnicache.query, (req, res) =>
  res.status(200).send(res.locals.queryResponse)
);

Contributors

Ahmed Chami

Aria Soltankhah

Truman Miller

Yousuf Elkhoga

Package Sidebar

Install

npm i @magnicache/server

Weekly Downloads

1

Version

1.0.9

License

MIT

Unpacked Size

80.4 kB

Total Files

8

Last publish

Collaborators

  • achami64
  • trumanmiller
  • yousuf-e