Skip to content

pg_graphql

Add in-database GraphQL support

pg_graphql · Add in-database GraphQL support

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2740pg_graphqlpg_graphql1.6.3FEATApache-2.0Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono
Relationships
Schemasgraphql
See Alsoomni_rest documentdb pg_net http pg_jsonschema pgjwt pg_session_jwt
1.6.3 fixes quoted primary keys in nodeId.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.6.319 18 17 16 15pg_graphql-
RPMPIGSTY1.6.319 18 17 16 15pg_graphql_$v-
DEBPIGSTY1.6.319 18 17 16 15postgresql-$v-pg-graphql-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
el8.aarch64N/APIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
el9.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
el9.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
el10.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
el10.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
d12.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
d12.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
d13.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
d13.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u22.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u22.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u24.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u24.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u26.x86_64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
u26.aarch64PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3PIGSTY 1.6.3
PackageVersionOSORGSIZEFile URL
pg_graphql_191.6.3el9.x86_64pigsty894.4 KiBpg_graphql_19-1.6.3-2PGSTY.el9.x86_64.rpm
pg_graphql_191.6.3el9.aarch64pigsty853.9 KiBpg_graphql_19-1.6.3-2PGSTY.el9.aarch64.rpm
pg_graphql_191.6.3el10.x86_64pigsty895.2 KiBpg_graphql_19-1.6.3-2PGSTY.el10.x86_64.rpm
pg_graphql_191.6.3el10.aarch64pigsty854.0 KiBpg_graphql_19-1.6.3-2PGSTY.el10.aarch64.rpm
postgresql-19-pg-graphql1.6.3d12.x86_64pigsty659.9 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~bookworm_amd64.deb
postgresql-19-pg-graphql1.6.3d12.aarch64pigsty566.5 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~bookworm_arm64.deb
postgresql-19-pg-graphql1.6.3d13.x86_64pigsty660.1 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~trixie_amd64.deb
postgresql-19-pg-graphql1.6.3d13.aarch64pigsty567.0 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~trixie_arm64.deb
postgresql-19-pg-graphql1.6.3u22.x86_64pigsty715.3 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~jammy_amd64.deb
postgresql-19-pg-graphql1.6.3u22.aarch64pigsty662.6 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~jammy_arm64.deb
postgresql-19-pg-graphql1.6.3u24.x86_64pigsty710.2 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~noble_amd64.deb
postgresql-19-pg-graphql1.6.3u24.aarch64pigsty656.9 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~noble_arm64.deb
postgresql-19-pg-graphql1.6.3u26.x86_64pigsty709.2 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~resolute_amd64.deb
postgresql-19-pg-graphql1.6.3u26.aarch64pigsty655.5 KiBpostgresql-19-pg-graphql_1.6.3-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_181.6.3el8.x86_64pigsty752.9 KiBpg_graphql_18-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_181.6.3el8.aarch64pigsty644.4 KiBpg_graphql_18-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_181.6.3el9.x86_64pigsty889.8 KiBpg_graphql_18-1.6.3-2PGSTY.el9.x86_64.rpm
pg_graphql_181.6.3el9.aarch64pigsty847.1 KiBpg_graphql_18-1.6.3-2PGSTY.el9.aarch64.rpm
pg_graphql_181.6.3el10.x86_64pigsty890.3 KiBpg_graphql_18-1.6.3-2PGSTY.el10.x86_64.rpm
pg_graphql_181.6.3el10.aarch64pigsty847.6 KiBpg_graphql_18-1.6.3-2PGSTY.el10.aarch64.rpm
postgresql-18-pg-graphql1.6.3d12.x86_64pigsty657.2 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~bookworm_amd64.deb
postgresql-18-pg-graphql1.6.3d12.aarch64pigsty563.0 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~bookworm_arm64.deb
postgresql-18-pg-graphql1.6.3d13.x86_64pigsty657.2 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~trixie_amd64.deb
postgresql-18-pg-graphql1.6.3d13.aarch64pigsty563.3 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~trixie_arm64.deb
postgresql-18-pg-graphql1.6.3u22.x86_64pigsty712.5 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~jammy_amd64.deb
postgresql-18-pg-graphql1.6.3u22.aarch64pigsty660.3 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~jammy_arm64.deb
postgresql-18-pg-graphql1.6.3u24.x86_64pigsty707.1 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~noble_amd64.deb
postgresql-18-pg-graphql1.6.3u24.aarch64pigsty654.0 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~noble_arm64.deb
postgresql-18-pg-graphql1.6.3u26.x86_64pigsty706.1 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~resolute_amd64.deb
postgresql-18-pg-graphql1.6.3u26.aarch64pigsty653.1 KiBpostgresql-18-pg-graphql_1.6.3-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_171.6.3el8.x86_64pigsty752.9 KiBpg_graphql_17-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_171.6.3el8.aarch64pigsty644.1 KiBpg_graphql_17-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_171.6.3el9.x86_64pigsty886.1 KiBpg_graphql_17-1.6.3-2PGSTY.el9.x86_64.rpm
pg_graphql_171.6.3el9.aarch64pigsty843.6 KiBpg_graphql_17-1.6.3-2PGSTY.el9.aarch64.rpm
pg_graphql_171.6.3el10.x86_64pigsty886.5 KiBpg_graphql_17-1.6.3-2PGSTY.el10.x86_64.rpm
pg_graphql_171.6.3el10.aarch64pigsty843.8 KiBpg_graphql_17-1.6.3-2PGSTY.el10.aarch64.rpm
postgresql-17-pg-graphql1.6.3d12.x86_64pigsty654.6 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~bookworm_amd64.deb
postgresql-17-pg-graphql1.6.3d12.aarch64pigsty561.3 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~bookworm_arm64.deb
postgresql-17-pg-graphql1.6.3d13.x86_64pigsty655.0 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~trixie_amd64.deb
postgresql-17-pg-graphql1.6.3d13.aarch64pigsty561.3 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~trixie_arm64.deb
postgresql-17-pg-graphql1.6.3u22.x86_64pigsty709.3 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~jammy_amd64.deb
postgresql-17-pg-graphql1.6.3u22.aarch64pigsty658.4 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~jammy_arm64.deb
postgresql-17-pg-graphql1.6.3u24.x86_64pigsty704.6 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~noble_amd64.deb
postgresql-17-pg-graphql1.6.3u24.aarch64pigsty651.7 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~noble_arm64.deb
postgresql-17-pg-graphql1.6.3u26.x86_64pigsty703.8 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~resolute_amd64.deb
postgresql-17-pg-graphql1.6.3u26.aarch64pigsty650.8 KiBpostgresql-17-pg-graphql_1.6.3-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_161.6.3el8.x86_64pigsty752.9 KiBpg_graphql_16-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_161.6.3el8.aarch64pigsty644.2 KiBpg_graphql_16-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_161.6.3el9.x86_64pigsty883.9 KiBpg_graphql_16-1.6.3-2PGSTY.el9.x86_64.rpm
pg_graphql_161.6.3el9.aarch64pigsty841.6 KiBpg_graphql_16-1.6.3-2PGSTY.el9.aarch64.rpm
pg_graphql_161.6.3el10.x86_64pigsty883.5 KiBpg_graphql_16-1.6.3-2PGSTY.el10.x86_64.rpm
pg_graphql_161.6.3el10.aarch64pigsty842.4 KiBpg_graphql_16-1.6.3-2PGSTY.el10.aarch64.rpm
postgresql-16-pg-graphql1.6.3d12.x86_64pigsty653.6 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~bookworm_amd64.deb
postgresql-16-pg-graphql1.6.3d12.aarch64pigsty560.4 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~bookworm_arm64.deb
postgresql-16-pg-graphql1.6.3d13.x86_64pigsty654.1 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~trixie_amd64.deb
postgresql-16-pg-graphql1.6.3d13.aarch64pigsty560.7 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~trixie_arm64.deb
postgresql-16-pg-graphql1.6.3u22.x86_64pigsty708.3 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~jammy_amd64.deb
postgresql-16-pg-graphql1.6.3u22.aarch64pigsty656.7 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~jammy_arm64.deb
postgresql-16-pg-graphql1.6.3u24.x86_64pigsty703.2 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~noble_amd64.deb
postgresql-16-pg-graphql1.6.3u24.aarch64pigsty650.4 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~noble_arm64.deb
postgresql-16-pg-graphql1.6.3u26.x86_64pigsty702.3 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~resolute_amd64.deb
postgresql-16-pg-graphql1.6.3u26.aarch64pigsty649.8 KiBpostgresql-16-pg-graphql_1.6.3-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_graphql_151.6.3el8.x86_64pigsty752.9 KiBpg_graphql_15-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_151.6.3el8.aarch64pigsty644.2 KiBpg_graphql_15-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_151.6.3el9.x86_64pigsty878.7 KiBpg_graphql_15-1.6.3-2PGSTY.el9.x86_64.rpm
pg_graphql_151.6.3el9.aarch64pigsty830.4 KiBpg_graphql_15-1.6.3-2PGSTY.el9.aarch64.rpm
pg_graphql_151.6.3el10.x86_64pigsty878.6 KiBpg_graphql_15-1.6.3-2PGSTY.el10.x86_64.rpm
pg_graphql_151.6.3el10.aarch64pigsty831.5 KiBpg_graphql_15-1.6.3-2PGSTY.el10.aarch64.rpm
postgresql-15-pg-graphql1.6.3d12.x86_64pigsty650.8 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~bookworm_amd64.deb
postgresql-15-pg-graphql1.6.3d12.aarch64pigsty557.8 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~bookworm_arm64.deb
postgresql-15-pg-graphql1.6.3d13.x86_64pigsty650.8 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~trixie_amd64.deb
postgresql-15-pg-graphql1.6.3d13.aarch64pigsty558.1 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~trixie_arm64.deb
postgresql-15-pg-graphql1.6.3u22.x86_64pigsty704.7 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~jammy_amd64.deb
postgresql-15-pg-graphql1.6.3u22.aarch64pigsty653.5 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~jammy_arm64.deb
postgresql-15-pg-graphql1.6.3u24.x86_64pigsty699.2 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~noble_amd64.deb
postgresql-15-pg-graphql1.6.3u24.aarch64pigsty647.3 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~noble_arm64.deb
postgresql-15-pg-graphql1.6.3u26.x86_64pigsty698.7 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~resolute_amd64.deb
postgresql-15-pg-graphql1.6.3u26.aarch64pigsty646.2 KiBpostgresql-15-pg-graphql_1.6.3-2PGSTY~resolute_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 by package name

pig install pg_graphql -v 19;   # install for PG 19
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

Create this extension with:

CREATE EXTENSION pg_graphql;

Usage

Sources: README, documentation, v1.6.1 release

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

Version Notes

pg_graphql 1.6.1 fixes double NON_NULL wrapping in byPk argument types that could break GraphiQL introspection, fixes mixed introspection/data queries returning partial results incorrectly, and updates documentation around introspection opt-in notices.

Table reader