A Boilerplate of GraphQL API built in Rust + Warp + Juniper + Diesel
Last updated Feb 26, 2026
96
Stars
6
Forks
0
Issues
0
Stars/day
Attention Score
14
Language breakdown
Rust 88.4%
PLpgSQL 9.1%
Dockerfile 2.5%
โธ Files
click to expand
README
Rust GraphQL API Boilerplate
This is a boilerplate built with Rust.
Features
- DB migration with Diesel
- Sign up
- Sign in
- Change password
- Profile Update
- JSON web token authentication
Stacks
- Rust
- Warp - Web server framework
- Juniper - GraphQL library
- Diesel - ORM
- DB: Postgres
- JSON Web Token : Authentication
Run
Without Docker
$ git clone https://github.com/mattdamon108/rustgraphqlapi_boilerplate
$ cd rustgraphqlapi_boilerplate
$ echo DATABASEURL=postgres://username:password@localhost/rustboilerplate > .env
$ diesel setup
$ diesel migration run
$ cargo run
Build with Docker
$ docker build -t rust_gql .
$ docker run --rm -d -p 3030:3030 --name runningrustgql rust_gql
Change the listening port from127.0.0.1to0.0.0.0inmain.rs. Because rust GraphQL API in docker container needs to listen to0.0.0.0instead of local interface in order for host to access to the API.
GraphiQL : connect to 127.0.0.1:3030 with browser
Schema
Query
query {
getMyProfile {
ok
error
user {
id
email
first_name
last_name
bio
avatar
}
}
}
Note: JSON web token is needed to be sent as authorization in header.
Mutation
Sign Up
mutation {
signUp(
email: "test@test.com"
password: "12345678"
firstName: "graphql"
lastName: "rust"
) {
ok
error
user {
id
email
first_name
last_name
bio
avatar
}
}
}
Sign In
mutation {
signIn(email: "test@test.com", password: "12345678") {
token
}
}
Change Password
Note: JSON web token is needed to be sent as authorization in header.
mutation {
changePassword(password: "87654321") {
ok
error
user {
id
email
first_name
last_name
bio
avatar
}
}
}
Change Profile
Note: JSON web token is needed to be sent as authorization in header.
mutation {
changeProfile(bio: "Rust fan") {
ok
error
user {
id
email
first_name
last_name
bio
avatar
}
}
}
Next to do
- [x] User Sign up
- [x] Hash User Password - with bcrypt crate
- [x] User Sign in based on Token authentication
- [x] User profile Update
- [x] ERROR HANDLING (important!)
- [x] Deploy using Docker after compile
- [ ] Optimizing the multithread
References
- http://alex.amiran.it/post/2018-08-16-rust-graphql-webserver-with-warp-juniper-and-mongodb.html
- https://github.com/graphql-rust/juniper/tree/master/juniper_warp
- https://blog.jawg.io/docker-multi-stage-build/
๐ More in this category