This project provides a complete example how to setup a Rust GraphQL web server using the following libraries:
- Rocket (web server)
- Diesel (database)
- Juniper (graphql)
- juniper-from-schema (graphql code generation)
- juniper-eager-loading (eager loading to avoid N+1 query bugs)
Create the (postgres) database and run migrations by running bin/setup
. We create both a development and test database.
Then compile and run the app
$ cargo run
Then go to http://localhost:8000/graphiql.
Or run the tests with
$ cargo test
This is by no means meant to demonstrate the best practices for making a web app with Rocket. Several important topics such as authentication and error handling is not addressed. It is meant to be used as a template for starting new apps.