pg_graphql

pg_graphql

pg_graphql : Add in-database GraphQL support

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2750
pg_graphql
pg_graphql
1.5.12
FEAT
Apache-2.0
Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Schemasgraphql
See Also
age
pg_jsonschema
jsquery
pg_net
http
pg_summarize
pg_tiktoken
wrappers

not an official release by Vonng

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
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 / PGPG18PG17PG16PG15PG14
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
PackageVersionOSORGSIZEFile URL
pg_graphql_181.5.12el8.x86_64pigsty871.9 KiBpg_graphql_18-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_181.5.12el8.aarch64pigsty693.1 KiBpg_graphql_18-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_181.5.12el9.x86_64pigsty880.2 KiBpg_graphql_18-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_181.5.12el9.aarch64pigsty739.4 KiBpg_graphql_18-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_181.5.12el10.x86_64pigsty880.3 KiBpg_graphql_18-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_181.5.12el10.aarch64pigsty739.2 KiBpg_graphql_18-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-graphql1.5.12d12.x86_64pigsty727.9 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-18-pg-graphql1.5.12d12.aarch64pigsty566.2 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-18-pg-graphql1.5.12d13.x86_64pigsty728.1 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-18-pg-graphql1.5.12d13.aarch64pigsty564.2 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-18-pg-graphql1.5.12u22.x86_64pigsty803.6 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-18-pg-graphql1.5.12u22.aarch64pigsty661.7 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-18-pg-graphql1.5.12u24.x86_64pigsty795.8 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-18-pg-graphql1.5.12u24.aarch64pigsty654.6 KiBpostgresql-18-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_171.5.12el8.x86_64pigsty872.4 KiBpg_graphql_17-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_171.5.12el8.aarch64pigsty693.2 KiBpg_graphql_17-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_171.5.12el9.x86_64pigsty881.1 KiBpg_graphql_17-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_171.5.12el9.aarch64pigsty739.5 KiBpg_graphql_17-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_171.5.12el10.x86_64pigsty879.8 KiBpg_graphql_17-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_171.5.12el10.aarch64pigsty739.1 KiBpg_graphql_17-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-graphql1.5.12d12.x86_64pigsty728.7 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-17-pg-graphql1.5.12d12.aarch64pigsty566.3 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-17-pg-graphql1.5.12d13.x86_64pigsty728.5 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-17-pg-graphql1.5.12d13.aarch64pigsty564.3 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-17-pg-graphql1.5.12u22.x86_64pigsty803.2 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-17-pg-graphql1.5.12u22.aarch64pigsty661.7 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-17-pg-graphql1.5.12u24.x86_64pigsty795.9 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-17-pg-graphql1.5.12u24.aarch64pigsty654.7 KiBpostgresql-17-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_161.5.12el8.x86_64pigsty871.8 KiBpg_graphql_16-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_161.5.12el8.aarch64pigsty692.7 KiBpg_graphql_16-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_161.5.12el9.x86_64pigsty880.7 KiBpg_graphql_16-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_161.5.12el9.aarch64pigsty739.6 KiBpg_graphql_16-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_161.5.12el10.x86_64pigsty880.8 KiBpg_graphql_16-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_161.5.12el10.aarch64pigsty739.4 KiBpg_graphql_16-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-graphql1.5.12d12.x86_64pigsty728.3 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-16-pg-graphql1.5.12d12.aarch64pigsty563.9 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-16-pg-graphql1.5.12d13.x86_64pigsty727.9 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-16-pg-graphql1.5.12d13.aarch64pigsty564.0 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-16-pg-graphql1.5.12u22.x86_64pigsty803.0 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-16-pg-graphql1.5.12u22.aarch64pigsty661.5 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-16-pg-graphql1.5.12u24.x86_64pigsty795.6 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-16-pg-graphql1.5.12u24.aarch64pigsty654.5 KiBpostgresql-16-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_151.5.12el8.x86_64pigsty871.8 KiBpg_graphql_15-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_151.5.12el8.aarch64pigsty692.9 KiBpg_graphql_15-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_151.5.12el9.x86_64pigsty879.6 KiBpg_graphql_15-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_151.5.12el9.aarch64pigsty739.5 KiBpg_graphql_15-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_151.5.12el10.x86_64pigsty879.6 KiBpg_graphql_15-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_151.5.12el10.aarch64pigsty739.3 KiBpg_graphql_15-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-graphql1.5.12d12.x86_64pigsty728.4 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-15-pg-graphql1.5.12d12.aarch64pigsty564.0 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-15-pg-graphql1.5.12d13.x86_64pigsty728.4 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-15-pg-graphql1.5.12d13.aarch64pigsty564.0 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-15-pg-graphql1.5.12u22.x86_64pigsty803.8 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-15-pg-graphql1.5.12u22.aarch64pigsty661.4 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-15-pg-graphql1.5.12u24.x86_64pigsty798.5 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-15-pg-graphql1.5.12u24.aarch64pigsty654.3 KiBpostgresql-15-pg-graphql_1.5.12-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_141.5.12el8.x86_64pigsty871.7 KiBpg_graphql_14-1.5.12-1PIGSTY.el8.x86_64.rpm
pg_graphql_141.5.12el8.aarch64pigsty692.5 KiBpg_graphql_14-1.5.12-1PIGSTY.el8.aarch64.rpm
pg_graphql_141.5.12el9.x86_64pigsty879.3 KiBpg_graphql_14-1.5.12-1PIGSTY.el9.x86_64.rpm
pg_graphql_141.5.12el9.aarch64pigsty739.4 KiBpg_graphql_14-1.5.12-1PIGSTY.el9.aarch64.rpm
pg_graphql_141.5.12el10.x86_64pigsty880.8 KiBpg_graphql_14-1.5.12-1PIGSTY.el10.x86_64.rpm
pg_graphql_141.5.12el10.aarch64pigsty739.0 KiBpg_graphql_14-1.5.12-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-graphql1.5.12d12.x86_64pigsty728.3 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~bookworm_amd64.deb
postgresql-14-pg-graphql1.5.12d12.aarch64pigsty563.6 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~bookworm_arm64.deb
postgresql-14-pg-graphql1.5.12d13.x86_64pigsty728.0 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~trixie_amd64.deb
postgresql-14-pg-graphql1.5.12d13.aarch64pigsty566.1 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~trixie_arm64.deb
postgresql-14-pg-graphql1.5.12u22.x86_64pigsty802.9 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~jammy_amd64.deb
postgresql-14-pg-graphql1.5.12u22.aarch64pigsty661.5 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~jammy_arm64.deb
postgresql-14-pg-graphql1.5.12u24.x86_64pigsty796.4 KiBpostgresql-14-pg-graphql_1.5.12-2PIGSTY~noble_amd64.deb
postgresql-14-pg-graphql1.5.12u24.aarch64pigsty654.5 KiBpostgresql-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