Rust + Hasura
This is an example of a Rust server that functions as a remote schema for Hasura.
It demonstrates:
- user login + signup
- JWT authorization w/ refresh cookie
- typesafe GraphQL requests
- uuid package integration
You can learn more about this stack from this repo and this talk.
Package Manager
Setup
- Your Hasura schema must have a table
user
, with aid
column of typeuuid
, and also ausername
column of typetext
. - You must also set an
ADMIN_SECRET
and aJWT_SECRET
on the graphql engine, and share these with the Rust server. - Use graphqurl to generate
./schema.json
gq $HASURA_ENDPOINT -H "x-hasura-admin-secret: $ADMIN_SECRET" --introspect --format json > ./schema.json
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"} |