Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ronanyeah/rust-hasura
Rust / Hasura / GraphQL
https://github.com/ronanyeah/rust-hasura
graphql hasura rust
Last synced: 12 days ago
JSON representation
Rust / Hasura / GraphQL
- Host: GitHub
- URL: https://github.com/ronanyeah/rust-hasura
- Owner: ronanyeah
- License: gpl-3.0
- Created: 2019-08-13T05:20:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-19T03:05:26.000Z (over 2 years ago)
- Last Synced: 2024-11-08T06:40:26.562Z (about 1 month ago)
- Topics: graphql, hasura, rust
- Language: Rust
- Homepage:
- Size: 46.9 KB
- Stars: 140
- Watchers: 8
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust - ronanyeah/rust-hasura - hasura/workflows/Rust/badge.svg?branch=master) (Applications / Web Servers)
- awesome-rust-cn - ronanyeah/rust-hasura - 演示如何用[Hasura](https://hasura.io/)将Rust (应用程序 Applications / Web服务器 Web Servers)
- awesome-hasura - Rust Hasura - Boilerplate/example of using Rust as a Remote Schema. It features login, signup, JWT, hashed passwords and typesafe requests. (Templates and Examples)
- awesome-rust - ronanyeah/rust-hasura - A demonstration of how a GraphQL server can be used as a remote schema with [Hasura](https://hasura.io/) ![Rust](https://github.com/ronanyeah/rust-hasura/workflows/Rust/badge.svg?branch=master) (Applications / Web Servers)
- fucking-awesome-rust - ronanyeah/rust-hasura - A demonstration of how a GraphQL server can be used as a remote schema with 🌎 [Hasura](hasura.io/) ![Rust](https://github.com/ronanyeah/rust-hasura/workflows/Rust/badge.svg?branch=master) (Applications / Web Servers)
- fucking-awesome-rust - ronanyeah/rust-hasura - A demonstration of how a GraphQL server can be used as a remote schema with 🌎 [Hasura](hasura.io/) ![Rust](https://github.com/ronanyeah/rust-hasura/workflows/Rust/badge.svg?branch=master) (Applications / Web Servers)
README
## Rust + Hasura ![Rust](https://github.com/ronanyeah/rust-hasura/workflows/Rust/badge.svg)
This is an example of a [Rust](https://www.rust-lang.org) server that functions as a [remote schema](https://hasura.io/docs/1.0/graphql/manual/remote-schemas/index.html) for [Hasura](https://hasura.io).
It demonstrates:
- user login + signup
- [JWT authorization w/ refresh cookie](https://hasura.io/blog/best-practices-of-using-jwt-with-graphql/)
- [typesafe GraphQL requests](https://docs.rs/graphql_client)
- [uuid](https://docs.rs/uuid) package integrationYou can learn more about this stack from [this talk](https://www.youtube.com/watch?v=ly05IV5isf4).
## Package Manager
[Cargo](https://doc.rust-lang.org/cargo/guide)
## Setup
- Your Hasura schema must have a table `user`, with a `id` column of type `uuid`, and also a `username` column of type `text`.
- Set an [`ADMIN_SECRET`](https://hasura.io/docs/1.0/graphql/manual/deployment/graphql-engine-flags/reference.html) and a [`JWT_SECRET`](https://hasura.io/docs/1.0/graphql/manual/auth/authentication/jwt.html) on the graphql engine, and share these with the Rust server as environment variables.
- Use [graphqurl](https://www.npmjs.com/package/graphqurl) to generate `schema.json`
- `gq $HASURA_ENDPOINT -H "x-hasura-admin-secret: $ADMIN_SECRET" --introspect --format json > ./graphql/schema.json`## Start
- `cargo run`## Environment Variables
Key | Example
--- | ---
`PORT` | `8000`
`HASURA_ENDPOINT` | `http://127.0.0.1:8080/v1/graphql`
`ADMIN_SECRET` | `foo`
`JWT_SECRET` | `{"type":"HS256","key":"3QQ6FD+o0+c7tzQQVfjpMkNDi2yARAAKzQQk8O2IKoxQQ4nF7EdAh8s3TwpHwrdQQ6R"}`