Giter VIP home page Giter VIP logo

postgres-graphql's Introduction

Postgres GraphQL

This is an example project using the following technologies to provide a GraphQL server.

The main benefit here is our GraphQL API types come directly from the Database, furthermore in our frontend applications we can automatically generate Typescript Types and Typed requests to interact with our API improving development agility and our application's integrity.

This README contains the following sections.

Getting Started

The only hard requirement is that you have docker and docker-compose installed, although naturally, you could install everything locally.

.env

First, let's copy the .env.example to .env. This file used by docker-compose will pass these environment variables into designated containers.

cp .env.example .env
sh ./init.sh
docker-compose up database migrations

Write some migrations in current.sql, once you're ready to commit.

Note I like to keep the minimum amount of logic in a specific commit to make your schema easier to read in the future, this also keeps your agility up in regards to developing new features.

docker-compose exec migrations yarn graphile-migrate commit -m "my commit message"

If you need to reset the database and rerun committed migrations.

docker-compose exec migrations yarn graphile-migrate reset --erase

GraphQL

Once we have our database up and running with a schema we can go ahead and start the GraphQL server.

docker-compose up database migrations gql

Or using up without and other parameters would start all available docker-compose services

docker-compose up database migrations gql

Note that because GraphQL specifies migrations as a dependency and migrations specify database as a dependency we could also start everything up with the following command, although this would only output logs from the gql service hiding other crucial logs.

docker-compose up database migrations gql

GraphiQL

Postgraphile comes with a nifty interface to aid in development called GraphiQL, this allows us to inspect our current GraphQL schema at the following URL.

http://localhost:5000/graphiql

postgres-graphql's People

Contributors

ncrmro avatar

Stargazers

 avatar

Watchers

 avatar  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.