Atlantis
By: Coral Fussman
Tags: Cache, Nodejs, Docker, GraphQL, Redis

The #1 light weight caching library

Problem We’re Solving

The industry standard for RESTful architecture has naturally relied on the Request/Response cycle for years. This is has proved reliable over time but inefficient. The standardized RESTful routes create a situation in which data is ALWAYS over fetched.

Enter GraphQL. A new way to specify EXACTLY what you want to receive back from the database. GraphQL is a database agnostic query language for querying your API. Meaning it can be used with relational or noSQL DB’s, no problem! GraphQL requests do away with all the CRUD routes and leave you with one clean endpoint.

The problem here now lies within caching. the Request/Response architecture has caching built in, as the CRUD methods are standardized and easy to update. GraphQL does not have this luxury out of the box as the queries to the API become highly specific. Caching is undeniably an invaluable tool, so with GraphQL’s popularity ever-increasing, developers have set out to solve this issue.

Solution

Atlantis is a light-weight library that solves the issue of storing and maintaining deeply-nested GraphQL queries.

This ensures the client always receives the most relevant data as mutations are made to the database.

Saving Time

Atlantis leverages Redis’s ‘in-memory’ quick lookup time to rapidly serve up cached graphQL responses regardless of size or structure.

Redis integration along with Pub/Sub architecture also allows for scaling as your needs grow and you require more cache space or backup cache workers.

Saving Space

New queries that bare resemblance to previous queries, are intelligently pulled from the existing cached nesting instead of creating a new key/value entry

How to Get Started

Alright now that we have our solution, lets walk through the easy install!

__________________________

After a quick npm install, require-in Atlantis to you’re backend as seen below.

The only requirements for Atlantis are Redis and a Schema.

That’s it!

__________________________

Code For Backend:

import express, { Application } from 'express'; import redis from 'redis'; const schema = require('./schema/schema'); const { atlantis } = require('atlantis-cache'); const redisClient = redis.createClient({ host: 'localhost', port: 6379, }); const app: Application = express(); app.use(express.json()); app.use('/atlantis', atlantis(redisClient, schema), async (req, res) => { return res.status(202).json({ data: res.locals.graphQLResponse }); });

After installing Redis and setting up your schema, pass in the redisClient and schema as the only two required arguments. This simplicity was, at the core focus of our product. Quite literally, “plug and play” and your good to go!

Check out the power of Atlantis for yourself! Visit our site findatlantis.io for a demo to see your potential speed gains!

Contribute

At SeeC Labs, the makers behind Atlantis, would love to hear any feedback and are always looking for passionate developers to contribute to products that impact the daily experience. If you’d like to contribute or collaborate, feel free to check out our GitHub and reach out!

If you have any questions around implementation we highly encourage it!

SeeC Labs

Coral Fussman — GitHub / LinkedIn

Sett Hein — GitHub / LinkedIn

Erik Matevosyan — GitHub / LinkedIn

Erik Rogel — GitHub / LinkedIn