GithubHelp home page GithubHelp logo

matt-sm / graphql-express-postgres Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 3.0 138 KB

A reference graphql api.

License: MIT License

JavaScript 100.00%
graphql nodejs babel knex graphql-tools express-jwt postgresql express

graphql-express-postgres's Introduction

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:"[email protected]", password:"password") }
mutation{createToken(email:"[email protected]", 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:

graphql-express-postgres's People

Contributors

matt-sm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.