A GraphQL with Apollo, Express and PostgreSQL boilerplate project.
- Apollo-server
- Queries, Mutations, Subscriptions, Error Handling, Playground, Custom Scalars, Authentication, Integration Testing, Schema directives
- Authentication
- powered by JWT
- Sign Up, Sign In
- PostgreSQL Database with Sequelize
- entities: Users & Posts
- Authorization
- protected resolvers
- Testing
- Node.js
- Express
- PostgreSQL
- Sequelize
- apollo-server-express
- JWT authentication
- Jest
- Eslint
git clone https://github.com/p8ul/apollo-graphql-express-boilerplate.git
cd apollo-graphql-express-boilerplate
yarn
- start PostgreSQL database
create two databases for testing and development
create a .env file and copy the keys from .env.example file
cp .env.example .env
# Your Graphql Port
PORT=4000
# Decoding Secret
SECRET="awesome_secret"
DATABASE_NAME= # the name of the PostgreSQL database
DATABASE_USERNAME= # username of the PostgreSQL database
DATABASE_PASSWORD= # password of the username
TEST_DATABASE_NAME= # test database name
yarn start
- navigate to
http://localhost:4000/graphql
- Open your browser to this address: http://localhost:4000 and run the available commands:
- Sign Up
mutation {
register(name: "admin", email: "[email protected]", password: "123456") {
token
}
}
- Login
mutation {
login(email: "[email protected]", password: "123456") {
token
}
}
- List Users
query {
users {
email
name
id
}
}
- Add Post
mutation {
addPost(
title: "Combo House"
body: "this is a post body"
file: "http://modern.realhomes.io/wp-content/uploads/2015/07/property-10-exterior-680x510.jpg"
) {
title
}
}
- List Post
query {
posts{
title
id
file
}
}
- Post added subscription
subscription {
postAdded {
title
body
file
}
}
- run
yarn test