Skip to content

matt-sm/graphql-express-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

614ead8 · Oct 1, 2018
Apr 5, 2018
Apr 5, 2018
Apr 6, 2018
May 3, 2018
Jan 24, 2018
Apr 5, 2018
Apr 5, 2018
Jan 25, 2018
Mar 11, 2018
Apr 6, 2018
Apr 30, 2018
Apr 30, 2018
Jan 22, 2018
Oct 1, 2018
Apr 5, 2018
May 3, 2018
May 3, 2018

Repository files navigation

graphql-express-postgres Build Status Coverage Status

A reference graphql api built with node and postgres.

The schema follows the classic user, posts, comments structure.

  • Uses Apollo Server
  • Examples of sql query caching using data loader
  • Schema definitions are built using graphql-tools.
  • Data access built on the Objection ORM and knex.
  • Authentication handled by express-jwt middleware.
  • For protected resolvers simply wrap the function in authenticated().
  • Tests use jest and execute against a database instance seeded with test data.

Install:

  • run locally with nodemon + babel: npm run dev
  • build and run on a server: npm start
  • db migrations: npm run migrate
  • format code: npm run prettier
  • lint code: npm run eslint
  • tests: createdb blog-test then npm test

Samples

Queries

{
  viewer {
    email
    posts {
      title
      comments {
        body
      }
    }   
  }
}

Mutations

mutation{addUser(name:"User", email:"user@test.com", password:"password") }
mutation{createToken(email:"user@test.com", password:"password") }

Database

Manually run the migrations/seeds

createdb blog-test
./node_modules/.bin/babel-node ./node_modules/.bin/knex migrate:latest --env test
./node_modules/.bin/babel-node ./node_modules/.bin/knex seed:run --env test

Prior Art:

Releases

No releases published

Packages

No packages published