pg_graphql

pg_graphql

pg_graphql : Add in-database GraphQL support

Overview

ID Extension Package Version Category License Language
2750
pg_graphql
pg_graphql
1.5.12
FEAT
Apache-2.0
Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Schemas graphql
See Also
age
pg_jsonschema
jsquery
pg_net
http
pg_summarize
pg_tiktoken
wrappers

not an official release by Vonng

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.5.12
18
17
16
15
14
pg_graphql -
RPM
PIGSTY
1.5.12
18
17
16
15
14
pg_graphql_$v -
DEB
PIGSTY
1.5.12
18
17
16
15
14
postgresql-$v-pg-graphql -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
el8.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
el9.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
el9.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
el10.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
el10.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
d12.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
d12.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
d13.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
d13.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
u22.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
u22.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
u24.x86_64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
u24.aarch64
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
PIGSTY 1.5.12
Package Version OS ORG SIZE File URL
pg_graphql_18 1.5.12 el8.x86_64 pigsty 871.9 KiB pg_graphql_18-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_18 1.5.12 el8.aarch64 pigsty 693.1 KiB pg_graphql_18-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_18 1.5.12 el9.x86_64 pigsty 880.2 KiB pg_graphql_18-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_18 1.5.12 el9.aarch64 pigsty 739.4 KiB pg_graphql_18-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_18 1.5.12 el10.x86_64 pigsty 880.3 KiB pg_graphql_18-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_18 1.5.12 el10.aarch64 pigsty 739.2 KiB pg_graphql_18-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-graphql 1.5.12 d12.x86_64 pigsty 727.9 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-18-pg-graphql 1.5.12 d12.aarch64 pigsty 566.2 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-18-pg-graphql 1.5.12 d13.x86_64 pigsty 728.1 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-18-pg-graphql 1.5.12 d13.aarch64 pigsty 564.2 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-18-pg-graphql 1.5.12 u22.x86_64 pigsty 803.6 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-18-pg-graphql 1.5.12 u22.aarch64 pigsty 661.7 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-18-pg-graphql 1.5.12 u24.x86_64 pigsty 795.8 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-18-pg-graphql 1.5.12 u24.aarch64 pigsty 654.6 KiB postgresql-18-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_17 1.5.12 el8.x86_64 pigsty 872.4 KiB pg_graphql_17-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_17 1.5.12 el8.aarch64 pigsty 693.2 KiB pg_graphql_17-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_17 1.5.12 el9.x86_64 pigsty 881.1 KiB pg_graphql_17-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_17 1.5.12 el9.aarch64 pigsty 739.5 KiB pg_graphql_17-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_17 1.5.12 el10.x86_64 pigsty 879.8 KiB pg_graphql_17-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_17 1.5.12 el10.aarch64 pigsty 739.1 KiB pg_graphql_17-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-graphql 1.5.12 d12.x86_64 pigsty 728.7 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-17-pg-graphql 1.5.12 d12.aarch64 pigsty 566.3 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-17-pg-graphql 1.5.12 d13.x86_64 pigsty 728.5 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-17-pg-graphql 1.5.12 d13.aarch64 pigsty 564.3 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-17-pg-graphql 1.5.12 u22.x86_64 pigsty 803.2 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-17-pg-graphql 1.5.12 u22.aarch64 pigsty 661.7 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-17-pg-graphql 1.5.12 u24.x86_64 pigsty 795.9 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-17-pg-graphql 1.5.12 u24.aarch64 pigsty 654.7 KiB postgresql-17-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_16 1.5.12 el8.x86_64 pigsty 871.8 KiB pg_graphql_16-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_16 1.5.12 el8.aarch64 pigsty 692.7 KiB pg_graphql_16-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_16 1.5.12 el9.x86_64 pigsty 880.7 KiB pg_graphql_16-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_16 1.5.12 el9.aarch64 pigsty 739.6 KiB pg_graphql_16-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_16 1.5.12 el10.x86_64 pigsty 880.8 KiB pg_graphql_16-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_16 1.5.12 el10.aarch64 pigsty 739.4 KiB pg_graphql_16-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-graphql 1.5.12 d12.x86_64 pigsty 728.3 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-16-pg-graphql 1.5.12 d12.aarch64 pigsty 563.9 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-16-pg-graphql 1.5.12 d13.x86_64 pigsty 727.9 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-16-pg-graphql 1.5.12 d13.aarch64 pigsty 564.0 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-16-pg-graphql 1.5.12 u22.x86_64 pigsty 803.0 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-16-pg-graphql 1.5.12 u22.aarch64 pigsty 661.5 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-16-pg-graphql 1.5.12 u24.x86_64 pigsty 795.6 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-16-pg-graphql 1.5.12 u24.aarch64 pigsty 654.5 KiB postgresql-16-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_15 1.5.12 el8.x86_64 pigsty 871.8 KiB pg_graphql_15-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_15 1.5.12 el8.aarch64 pigsty 692.9 KiB pg_graphql_15-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_15 1.5.12 el9.x86_64 pigsty 879.6 KiB pg_graphql_15-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_15 1.5.12 el9.aarch64 pigsty 739.5 KiB pg_graphql_15-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_15 1.5.12 el10.x86_64 pigsty 879.6 KiB pg_graphql_15-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_15 1.5.12 el10.aarch64 pigsty 739.3 KiB pg_graphql_15-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-graphql 1.5.12 d12.x86_64 pigsty 728.4 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-15-pg-graphql 1.5.12 d12.aarch64 pigsty 564.0 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-15-pg-graphql 1.5.12 d13.x86_64 pigsty 728.4 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-15-pg-graphql 1.5.12 d13.aarch64 pigsty 564.0 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-15-pg-graphql 1.5.12 u22.x86_64 pigsty 803.8 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-15-pg-graphql 1.5.12 u22.aarch64 pigsty 661.4 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-15-pg-graphql 1.5.12 u24.x86_64 pigsty 798.5 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-15-pg-graphql 1.5.12 u24.aarch64 pigsty 654.3 KiB postgresql-15-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_14 1.5.12 el8.x86_64 pigsty 871.7 KiB pg_graphql_14-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_14 1.5.12 el8.aarch64 pigsty 692.5 KiB pg_graphql_14-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_14 1.5.12 el9.x86_64 pigsty 879.3 KiB pg_graphql_14-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_14 1.5.12 el9.aarch64 pigsty 739.4 KiB pg_graphql_14-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_14 1.5.12 el10.x86_64 pigsty 880.8 KiB pg_graphql_14-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_14 1.5.12 el10.aarch64 pigsty 739.0 KiB pg_graphql_14-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-graphql 1.5.12 d12.x86_64 pigsty 728.3 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-14-pg-graphql 1.5.12 d12.aarch64 pigsty 563.6 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-14-pg-graphql 1.5.12 d13.x86_64 pigsty 728.0 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-14-pg-graphql 1.5.12 d13.aarch64 pigsty 566.1 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-14-pg-graphql 1.5.12 u22.x86_64 pigsty 802.9 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-14-pg-graphql 1.5.12 u22.aarch64 pigsty 661.5 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-14-pg-graphql 1.5.12 u24.x86_64 pigsty 796.4 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-14-pg-graphql 1.5.12 u24.aarch64 pigsty 654.5 KiB postgresql-14-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb

Source

pig build pkg pg_graphql;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_graphql;		# install via package name, for the active PG version

pig install pg_graphql -v 18;   # install for PG 18
pig install pg_graphql -v 17;   # install for PG 17
pig install pg_graphql -v 16;   # install for PG 16
pig install pg_graphql -v 15;   # install for PG 15
pig install pg_graphql -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_graphql;

Usage

pg_graphql: Add in-database GraphQL support

pg_graphql reflects a GraphQL schema from your existing SQL schema, enabling GraphQL queries directly inside PostgreSQL without additional servers or middleware.

Schema Reflection

Tables, foreign keys, and enums are automatically mapped to GraphQL types:

CREATE TABLE account (
    id serial PRIMARY KEY,
    email varchar(255) NOT NULL,
    created_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)
);

CREATE TYPE blog_post_status AS ENUM ('PENDING', 'RELEASED');

CREATE TABLE blog_post (
    id uuid NOT NULL DEFAULT gen_random_uuid() 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
);

This schema automatically generates GraphQL types (Account, Blog, BlogPost) with relationships derived from foreign keys.

Name Inflection

Enable automatic snake_case to camelCase/PascalCase conversion:

COMMENT ON SCHEMA public IS e'@graphql({"inflect_names": true})';

Querying

Execute a GraphQL query via the graphql.resolve function:

SELECT graphql.resolve($$
    {
      accountCollection(first: 1) {
        edges {
          node {
            id
            email
            blogCollection {
              edges {
                node {
                  name
                  blogPostCollection(filter: { status: { eq: RELEASED } }) {
                    edges {
                      node {
                        title
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
$$);

Features

  • Table queries appear as pageable collections on the root Query type
  • Foreign key relationships create nested query fields automatically
  • Mutations support bulk insert, update, and delete
  • Filtering, ordering, and pagination are built in
  • PostgreSQL Row-Level Security (RLS) policies are respected
Last updated on