Atlantis is a light-weight library that leverages Redis key-value store to dynamically cache GraphQL queries as responses. Atlantis is able to dynamically store deeply-nested queries and maintain the most recent and relevant data as mutations are made to the database. Queries that are more shallow and within the scope of previous queries are pulled directly from the cache, offering further flexibility and precision, without additional network requests or overriding previous key-values.
This package is meant to work in conjunction with Redis. For more information about Redis: check out: Redis
-
Mac-HomeBrew:
- At the terminal,
brew install redis
- Start redis server with
redis-server
- Test if redis server is running:
redis-cli ping
. If it replies “PONG”, then it’s good to go! - Default port is
6379
(Keep note of the port)
- At the terminal,
-
Linux or non-Homebrew:
- Download appropriate version of Redis from redis.io/download
- Follow the instructions
- Once installation is completed, start redis server with
redis-server
- Default port is
6379
(Keep note of the port)
Install Atlantis-Cache as an npm module and save it to your package.json as a dependency.
npm i atlantis-cache
const express = require('express');
const redis = require('redis');
const { graphql } = require('graphql');
const schema = require('./schema/schema');
const { atlantis } = require('atlantis-cache');
const app = express();
// Configure your redis client
const redisClient = redis.createClient({
host: 'localhost',
port: 6379,
});
// Define your endpoint for graphQL queries and pass in your redis, and schema
app.use('/graphql', atlantis(redisClient, schema), async (req, res) => {
return res.status(202).json({ data: res.locals.graphQLResponse });
});
- Coral Fussman - Github | Linkedin
- Sett Hein -Github | Linkedin
- Erik Matevosyan - Github | Linkedin
- Erik Rogel - Github | Linkedin
This product is licensed under the MIT License - see the LICENSE.md file for details.
This product is accelerated by OS Labs.