This is an example of a Rust server that functions as a remote schema for Hasura.
It features login, signup, JWT creation, hashed passwords and typesafe requests to Hasura (including integration of Rust's uuid package).
- Your Hasura schema must have a table
user
, with a columnid
of typeuuid
, and also a columnpassword
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
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"} |