GraphQL AST Demo

This sample project demonstrates how to use a GraphQL Abstract Syntax Tree (AST) to help you make more efficient database queries. It uses a MongoDB database for demonstration purposes but the same principles can be mapped to whichever database you are using.

WARNING: THIS CODE IS NOT PRODUCTION-READY!

Installation

Make sure you have MongoDB installed on your machine. Read the MongoDB docs for more information on how to do that.

Install the dependencies:

npm install

Rename the .env.example file to .env and provide a value for the JWT_SECRET. For playing around with this demo, set it to whatever you like. However, in the real world, this value should be a super strong key.

Run in development mode for live reloading:

npm run dev

Or run without live reloading:

npm start

Database Seeding

The project is set up to use a database called test. There is demo data in the db directory which is used to seed the database.

The database is cleared and seeded everytime the server is restarted.

Sample Queries

All types and queries are defined in server.js. Each registered query demonstrates a different aspect of how to use the GraphQL AST to make efficient database calls.

License

MIT