Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jayy-lmao/rust-graphql-docker
Scratch-Containerised Rust GraphQL-API using Dataloaders
https://github.com/jayy-lmao/rust-graphql-docker
actix-web dataloaders docker graphql graphql-server juniper rust rust-lang
Last synced: 4 months ago
JSON representation
Scratch-Containerised Rust GraphQL-API using Dataloaders
- Host: GitHub
- URL: https://github.com/jayy-lmao/rust-graphql-docker
- Owner: jayy-lmao
- Created: 2019-12-26T10:23:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-19T02:58:13.000Z (about 3 years ago)
- Last Synced: 2024-09-28T21:42:30.763Z (5 months ago)
- Topics: actix-web, dataloaders, docker, graphql, graphql-server, juniper, rust, rust-lang
- Language: Rust
- Homepage:
- Size: 105 KB
- Stars: 94
- Watchers: 5
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-starred - jayy-lmao/rust-graphql-docker - Scratch-Containerised Rust GraphQL-API using Dataloaders (docker)
README
# Dockerize Graphql Rust
***More current version at https://github.com/jayy-lmao/rust-cult-graphql-server***
This project is currently for demonstrating the use of dataloaders in a rust-based graphql server.
This demo uses:- `actix-web` a high-performance webserver for rust https://www.techempower.com/benchmarks/
- `juniper` a popular rust graphql framework https://github.com/graphql-rust/juniper
- A dockerfile which creates a _from scratch_ minimal sized container
- Cults (more to be added)There are definitely some improvements to be made in db requests, pagination etc. Let me know if you spot anything you think is top-priority!
## Running locally
simple as `docker-compose up`, crazy!
Then navigate to http://localhost:8000/graphql## TODO
- [x] DB connection
- [x] Expose graphql
- [ ] Mutations!
- [x] Create
- [ ] Update
- [ ] Delete
- [ ] Context to later use in Dataloaders and Auth
- [x] Dataloaders
- [ ] Auth?
- [ ] DB pool## Schema
```graphql
type Cult {
id: Int!
name: String!
members: [Person!]!
}type Mutation {
createPerson(data: NewPerson!): Person!
createCult(data: NewCult!): Cult!
}input NewCult {
name: String!
}input NewPerson {
name: String!
cult: Int
}type Person {
id: Int!
name: String!
cult: Cult
}type Query {
personById(id: Int!): Person!
persons: [Person!]!
cultById(id: Int!): Cult!
cults: [Cult!]!
}
```## References
Original Rest API & DB connection is inspired by:
https://turreta.com/2019/09/21/rest-api-with-rust-actix-web-and-postgresql-part-3/Graphql setup is inspired by:
https://www.freecodecamp.org/news/building-powerful-graphql-servers-with-rust/Rust containerization initially inspired by:
https://alexbrand.dev/post/how-to-package-rust-applications-into-minimal-docker-containers/## Other stuff
If you are ever looking at setting up a Redis pubsub for keeping multiple servers in sync; check out https://github.com/jayy-lmao/rust-chat-bb8-ws
If you want a more up-to-date version using *actix-web* and *async-graphql* see https://github.com/jayy-lmao/rust-cult-graphql-server