Skip to content

oslabs-beta/dashQL

Repository files navigation

dashQL_Logo

graphql redis typescript vite

react chartjs node postgres

About

dashQL is a lightweight GraphQL caching tool utilizing Redis to cache queries at the field level to further improve reponse time and decrease the number of redundant requests required

Table of Contents

  1. Features
  2. Getting Started
  3. Demo
  4. Contributing
  5. Authors

Features

  • Allows for caching at the field level from the GraphQL abstract syntax tree
  • Ability to handle query requests both with and without an argument
  • Ability to cache deeply nested queries

Getting Started

  1. Install redis and define host and port in server file
const redisClient = redis.createClient({
host: "localhost",
port: 6379,
});
  1. Download dashQL as an npm module and save it to your package.json as a dependency
npm install dashql
  1. Import dashQL into server file
const dashQL = require('dashQL');
  1. Create an instance of dashQL by passing in redisClient in server file
const dashQL = new dashQL(redisClient);
  1. On your server file which handles graphQL requests, name the endpoint '/dashQL' and put in dashQL as your middleware and return res.locals back to client
app.use('/dashQL', dashQL, (req: Request, res: Response) => {
  return res.status(200).send(res.locals);
});
  1. Enjoy significantly faster response times specifically at the field level not just per query string!

Demo

Feel free to visit our website to get an interactive demonstration of how our caching tool works and view the significantly improved response times

After entering our site, you will be met with a demonstration with the ability to run GraphQL queries with an interactive selection tool utilizing the Star Wars API.

  1. Select the fields you would like to query and a preview of the GraphQL query will be shown

name mass

  1. Click the 'Run Query' button to see the GraphQL query result. The metrics above will show the uncached response time populated on the graph and a cache hit/miss result will be logged to the bar charts. A cache miss will be logged the first time a unique query is run indicating that the query was not found in our cache and will be stored.

name-mass-time

  1. This time, select an additional field to query. Then click the 'Run Query' button. The response time has drastically decreased as the previous field level queries were stored in the cache and the server only has to go to the database for one field.

name-mass-eye color

  1. Feel free to play around with nested queries by selecting 'Species' or queries without an '_id' argument.

nested In this last example, you will notice the response time is decreased even further on the third query request as now all information is coming from the cache.

  1. Lastly, click the 'Clear Cache' button to clear the cache and start over.

Contributing to dashQL

The team at dashQL is excited you are interested in contributing to dashQL.

  1. Fork repo from the dev branch
  2. Create your feature branch (git checkout -b feature/yourFeature)
  3. Stage and commit your changes (git commit -m "added cool new feature")
  4. Push to branch (git push origin feature/yourFeature)
  5. Open a pull request to dev which will be reviewed by one of the dashQL authors prior to merge

Roadmap for Future Development

  • Handle mutations
  • End-to-end testing
  • Additional eviction strategies
  • Security features

Authors

Dan Bonney LinkedIn | Github
Meredith Fronheiser LinkedIn | Github
Kevin Klochan LinkedIn | Github
Drew Williams LinkedIn | Github

Please ⭐ our repo if you've found this useful, we want to be able to help as many of developers as we can!

About

Optimized lightweight caching solution for GraphQL utilizing Redis at the query field level

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages