In this article you will look at a NodeJS app coming with an integration of GraphQL and Sequelize connected to PostgreSQL to bridge normalized, relational data (in 1-n, m-n cardinalities) to document-based representations of the data. I’m going to provide example GraphQL READ-only queries and show how they get translated into effective SQL statements through the Object Relational Mapper  Sequelize.

For a quick start, this article provides a working example on this  GH repo.

Project setup

  • clone the graphql-sequelize-pg project :
  • git clone **https://github.com/thomasreinecke/graphql-sequelize-pg.git- the project will be cloned into yourROJECT_HOME** directory
  • on PROJECT_HOME run yarn to install the node dependencies
  • install a PostgreSQL database server, make sure its running and accessible (this tutorial won’t cover this topic, however you’ll find plenty of resources on the net)
  • on PROJECT_HOME edit the .envfile and apply your database settings
NODE_ENV=development
PORT=9000
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=its-my-database
DB_USERNAME=its-me
DB_PASSWORD=its-my-password
DB_SCHEMA=its-my-schema
DB_DIALECT=postgres

#nodejs #sequelize #graphql

A boilerplate for GraphQL, Sequelize, PostgreSQL on Node
5.65 GEEK