kilianc / pg_graphql

GraphQL support for PostgreSQL

Home Page:https://supabase.github.io/pg_graphql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pg_graphql

PostgreSQL version License Tests


Documentation: https://supabase.github.io/pg_graphql

Source Code: https://github.com/supabase/pg_graphql


Query your existing PostgreSQL database with GraphQL

pg_graphql inspects your PostgreSQL schema and reflects a GraphQL schema with resolvers.

  • Performant: +2k requests/second
  • Always up-to-date: Reflected from the SQL schema
  • Pagination: Relay compliant
  • Serverless: Runs in your database with no additional server required
  • Open Source: Apache License 2.0

pg_graphql is pre-alpha software under active development

Overview

pg_graphql provides an SQL schema -> GraphQL schema reflection engine and an associated GraphQL query -> SQL query transpiler.

The extension keeps schema generation, query parsing, and resolvers all neatly contained on your database. This enables any programming language that can connect to PostgreSQL to query the database via GraphQL with no additional servers, processes, or libraries.

TL;DR

The SQL schema

create table account(
    id serial primary key,
    email varchar(255) not null,
    encrypted_password varchar(255) not null,
    created_at timestamp not null,
    updated_at timestamp not null
);

create table blog(
    id serial primary key,
    owner_id integer not null references account(id),
    name varchar(255) not null,
    description varchar(255),
    created_at timestamp not null,
    updated_at timestamp not null
);

create type blog_post_status as enum ('PENDING', 'RELEASED');

create table blog_post(
    id uuid not null default uuid_generate_v4() primary key,
    blog_id integer not null references blog(id),
    title varchar(255) not null,
    body varchar(10000),
    status blog_post_status not null,
    created_at timestamp not null,
    updated_at timestamp not null
);

Translates into a GraphQL schema exposing each table as a pageable collection with relationships defined by the foreign keys.

GraphiQL

About

GraphQL support for PostgreSQL

https://supabase.github.io/pg_graphql

License:Apache License 2.0


Languages

Language:PLpgSQL 93.5%Language:Nix 2.0%Language:C 1.5%Language:Python 1.0%Language:Dockerfile 0.8%Language:HTML 0.7%Language:Makefile 0.3%Language:Shell 0.2%