This is a GraphQL API boilerplate built with Typescript, graphQL-yoga, typeORM, JWT
- Web Server Application : graphQL-yoga
- ORM : typeORM
- JWT : jsonwebtoken
- User Sign Up & Sign In
- Change a Password, Profile
- Create a database
postgres=# CREATE DATABASE any;
- Create a user as owner of database
postgres=# CREATE USER any WITH ENCRYPTED PASSWORD 'any';
postgres=# ALTER DATABASE any OWNER TO any;
- Grant all privileges to user for the database
postgres=# GRANT ALL PRIVILEGES ON DATABASE any TO any;
- Configure
.env
JWT_SECRET_KEY=jwt-secret
DB_NAME=any
DB_ENDPOINT=localhost
DB_USERNAME=any
DB_PASSWORD=any
Set a JWT secret key
- Dev
$ yarn dev
- Prod
$yarn build
$yarn start
Connect to http://localhost:4000
You need to set the Http request headers X-JWT
: {JWT_token}
mutation {
SignUp(email: "test@test.com", password: "12345678", fullName: "graphql", nickName: "ts") {
ok
error
user {
id
email
fullName
nickName
bio
avatar
createdAt
updatedAt
}
token
}
}
mutation {
SignIn(email: "test@test.com", password: "12345678") {
ok
error
token
}
}
mutation {
ChangePassword(password: "87654321") {
ok
error
user {
id
email
fullName
nickName
bio
avatar
createdAt
updatedAt
}
}
}
mutation {
ChangeProfile(bio: "developer", avatar: "developer.png") {
ok
error
profile {
id
email
fullName
nickName
bio
avatar
createdAt
updatedAt
}
}
}
query {
getMyProfile {
ok
error
profile {
id
email
fullName
nickName
bio
avatar
createdAt
updatedAt
}
}
}
- DalYoon / graphql-yoga-with-typeorm-boilerplate (https://github.com/DalYoon/graphql-yoga-with-typeorm-boilerplate)