You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pg_graphql adds GraphQL support to your PostgreSQL database.
Performant
Consistent
Serverless
Open Source
Overview
pg_graphql reflects a GraphQL schema from the existing SQL schema.
The extension keeps schema translation and query resolution neatly contained on your database server. 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
createtableaccount(
id serialprimary key,
email varchar(255) not null,
created_at timestampnot null,
updated_at timestampnot null
);
createtableblog(
id serialprimary key,
owner_id integernot nullreferences account(id),
name varchar(255) not null,
description varchar(255),
created_at timestampnot null,
updated_at timestampnot null
);
createtypeblog_post_statusas enum ('PENDING', 'RELEASED');
createtableblog_post(
id uuid not null default uuid_generate_v4() primary key,
blog_id integernot nullreferences blog(id),
title varchar(255) not null,
body varchar(10000),
status blog_post_status not null,
created_at timestampnot null,
updated_at timestampnot null
);
-- This enables default inflection, which automatically renames-- snake_case to PascalCase for type names, and snake_case to camelCase for field names.-- See https://supabase.github.io/pg_graphql/configuration/#inflection for more details.COMMENT ON SCHEMA public IS e'@graphql({"inflect_names": true})';
Translates into a GraphQL schema displayed below.
Each table receives an entrypoint in the top level Query type that is a pageable collection with relationships defined by its foreign keys. Tables similarly receive entrypoints in the Mutation schema that enable bulk operations for insert, update, and delete.