Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clean boilerplate for graphql services using actix-web, rhai, async-graphql, surf, rbatis, graphql-client, handlebars-rust, jsonwebtoken, and mysql / postgresql.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

zzy/actix-web-async-graphql-rbatis

Repository files navigation

Clean boilerplate for graphql services using actix-web, rhai, async-graphql, surf, rbatis, graphql-client, handlebars-rust, jsonwebtoken, and mysql / postgresql.

See also:tide-async-graphql-mongodb

Features

  • Graphql Services
    • User register
    • Salt and hash a password with PBKDF2 - 使用 PBKDF2 对密码进行加密(salt)和散列(hash)运算
    • Sign in
    • JSON web token authentication - JWT 鉴权整合
    • Change password
    • Profile Update
    • User: query & mutation
    • Project: query & mutation
  • Web Application
    • Client request, bring & parse GraphQL data
    • Render data to template engine
    • Define custom helper with Rhai scripting language

Stacks

How to run?

git clone https://github.com/zzy/actix-web-async-graphql.gitcd actix-web-async-graphqlcargo build

Frontend - actix-web server

cd frontend-handlebars

Rename file.env.example to.env, or put the environment variables into a.env file:

ADDRESS=127.0.0.1PORT=3000GRAPHQL_PORT=8080GRAPHQL_PATH=graphqlGRAPHIQL_PATH=graphiql

Build & Run:

cargo run

Then connect tohttp://127.0.0.1:3000 with browser.

Client Image

Backend - Graphql Server

cd backend

Rename file.env.example to.env, or put the environment variables into a.env file:

ADDRESS=127.0.0.1PORT=8080GRAPHQL_PATH=graphqlGRAPHIQL_PATH=graphiqlMYSQL_URI=mysql://root:mysql@localhost:3306/budshomePOSTGRES_URI=postgres://root:mysql@localhost:5432/budshomeSITE_KEY=0F4EHz+1/hqVvZjuB8EcooQs1K6QKBvLUxqTHt4tpxE=CLAIM_EXP=10000000000

Build & Run:

cargo run

GraphiQL: connect tohttp://127.0.0.1:8080/graphiql with browser.

Graphql Image

Queries

  • getUserByEmail(...): User!
  • getUserByUsername(...): User!
  • userSignIn(...): SignInfo!
  • allUsers(...): [User!]!
  • allProjects: [Project!]!
  • allProjectsByUser(...): [Project!]!

MUTATIONS

  • userRegister(...): User!
  • userChangePassword(...): User!
  • userUpdateProfile(...): User!
  • addProject(...): Project!

Sample Usage

Sample mutation for user register:

mutation {  userRegister(    newUser: {       email: "example@budshome.com",       username: "我是谁",       password: "wo#$shi^$shui"     }  ) {    id    email    username  }}

Sample query for user sign in:

{  userSignIn(    userAccount: {      email: "example@budshome.com"      username: ""      password: "wo#$shi^$shui"    }  ) {    email    username    token  }}

When submit methoduserSignIn, a token would be generated, use this token for query all users and every user's projects:

{  allUsers(    token: "fyJ0eXAiOiJKV1Q..."  ) {    id    email    username    projects {      id      userId      subject      website    }  }}

Sample query and mutation for projects was similar to users.

Contributing

You are welcome in contributing to this project.

About

Clean boilerplate for graphql services using actix-web, rhai, async-graphql, surf, rbatis, graphql-client, handlebars-rust, jsonwebtoken, and mysql / postgresql.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp