- git init
- heroku login
- heroku create
- git push heroku master
- heroku addons:create heroku-postgresql:hobby-dev
- heroku config
- Copy the POSTGRES_URL to .env file
- Import db.sql
- npm install
- node index.js
Getting relational fields mixed with DB stored or static data:
{
users {
id
fullname,
role {
name
}
}
roles {
name
}
books {
id
title
publisher {
name
}
}
publishers {
name
books {
title
}
}
}
Filtering data
{
books(publisherId: 2) {
id
title
publisher {
id
name
}
}
}
Posting data using mutations:
A simple, static example
mutation {
likeBook(bookId: 2) {
id,
title,
likes
}
}
A dynamic, db example of the post data
mutation {
createUser(newUserInfo: {
fullname: "Jack"
email: "user3@email.com"
role: "editor"
}) {
id
fullname
email
role {
name
}
}
}