Instant GraphQL APIs for Your Databases

alpha2phi
6 min readJul 16, 2021

Auto-generate GraphQL APIs for your databases.

Photo by Tobias Fischer on Unsplash

Overview

I talked about generating REST APIs in 5 minutes and using GraphQL to serve machine learning models in earlier articles. GraphQL, by Facebook, is gaining popularity among developers. In this article let’s explore open-source platforms that can help us automatically generate GraphQL APIs for databases.

Setting up a PostgreSQL Database

Let’s set up a PostgreSQL database with data for demonstration purposes.

docker-compose

I am going to use the following docker-compose.yml to set up PostgreSQL and adminer to manage the database.

Note that I set the default network to my-network. All the Docker instances should use the same network to communicate with each other.

The docker-compose file and the SQL files can be found in this repository.

Run docker compose upto create and run the Docker instances.

PostgreSQL Docker instance

Adminer

Login to adminer at http://localhost:8081.

  • System: PostgreSQL
  • Server: pgsql (follow the name in docker-compose.yml)
  • Username: postgres
  • Password: postgres
alpha2phi

Software engineer, Data Science and ML practitioner.