MongoDB data(include structure & documents) file is /data/budshome.sql
.
If you need mongodb cloud count, email to me or wechat(微信): yupen-com, please.
git clone https://github.com/zzy/tide-async-graphql-mongodb.git
cd tide-async-graphql-mongodb
cargo build
cd backend
Rename file .env.example
to .env
, or put the environment variables into a .env
file:
ADDRESS=127.0.0.1
PORT=8000
GRAPHQL_PATH=graphql
GRAPHIQL_PATH=graphiql
MONGODB_URI=mongodb://mongo:[email protected]:27017
MONGODB_BUDSHOME=budshome
SITE_KEY=0F4EHz+1/hqVvZjuB8EcooQs1K6QKBvLUxqTHt4tpxE=
CLAIM_EXP=10000000000
Then, build & run:
cargo run
GraphiQL: connect to http://127.0.0.1:8000/graphiql with browser.
- getUserByEmail(...): User!
- getUserByUsername(...): User!
- userSignIn(...): SignInfo!
- allUsers(...): [User!]!
- allProjects: [Project!]!
- allProjectsByUser(...): [Project!]!
- userRegister(...): User!
- userChangePassword(...): User!
- userUpdateProfile(...): User!
- addProject(...): Project!
Sample mutation for user register:
mutation {
userRegister(
newUser: {
email: "[email protected]",
username: "我是谁",
password: "wo#$shi^$shui"
}
) {
id
email
username
}
}
Sample query for user sign in:
{
userSignIn(
userAccount: {
email: "[email protected]"
username: ""
password: "wo#$shi^$shui"
}
) {
email
username
token
}
}
When submit method userSignIn
, 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.
You are welcome in contributing to this project.