Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
db.sql
index.js
package-lock.json
package.json
pgAdapter.js
resolvers.js
schema.graphql
schema.js

README.md

heroku-express-pg-graphapi

Set up and deploy on heroku

  1. git init
  2. heroku login
  3. heroku create
  4. git push heroku master

Set up postgres heroku instance

  1. heroku addons:create heroku-postgresql:hobby-dev
  2. heroku config
  3. Copy the POSTGRES_URL to .env file
  4. Import db.sql

Run

  1. npm install
  2. node index.js

Sample Queries

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
	  }
  }
}
You can’t perform that action at this time.