跳转到主要内容

pg_graphql

Add in-database GraphQL support

pg_graphql : Add in-database GraphQL support

Overview

ID Extension Package Version Category License Language
2740 pg_graphql pg_graphql 1.6.3 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 omni_rest documentdb pg_net http pg_jsonschema pgjwt pg_session_jwt
1.6.3 fixes quoted primary keys in nodeId.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.6.3 19 18 17 16 15 pg_graphql -
RPM PIGSTY 1.6.3 19 18 17 16 15 pg_graphql_$v -
DEB PIGSTY 1.6.3 19 18 17 16 15 postgresql-$v-pg-graphql -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
el8.aarch64 N/A PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
el9.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
el9.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
el10.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
el10.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
d12.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
d12.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
d13.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
d13.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u22.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u22.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u24.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u24.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u26.x86_64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
u26.aarch64 MISS PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3 PIGSTY 1.6.3
Package Version OS ORG SIZE File URL
pg_graphql_18 1.6.3 el8.x86_64 pigsty 752.9 KiB pg_graphql_18-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_18 1.6.3 el8.aarch64 pigsty 644.4 KiB pg_graphql_18-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_18 1.6.3 el9.x86_64 pigsty 752.4 KiB pg_graphql_18-1.6.3-1PGSTY.el9.x86_64.rpm
pg_graphql_18 1.6.3 el9.aarch64 pigsty 692.1 KiB pg_graphql_18-1.6.3-1PGSTY.el9.aarch64.rpm
pg_graphql_18 1.6.3 el10.x86_64 pigsty 752.4 KiB pg_graphql_18-1.6.3-1PGSTY.el10.x86_64.rpm
pg_graphql_18 1.6.3 el10.aarch64 pigsty 692.3 KiB pg_graphql_18-1.6.3-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-graphql 1.6.3 d12.x86_64 pigsty 660.2 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-graphql 1.6.3 d12.aarch64 pigsty 560.3 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-graphql 1.6.3 d13.x86_64 pigsty 660.7 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~trixie_amd64.deb
postgresql-18-pg-graphql 1.6.3 d13.aarch64 pigsty 560.3 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~trixie_arm64.deb
postgresql-18-pg-graphql 1.6.3 u22.x86_64 pigsty 714.4 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~jammy_amd64.deb
postgresql-18-pg-graphql 1.6.3 u22.aarch64 pigsty 656.3 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~jammy_arm64.deb
postgresql-18-pg-graphql 1.6.3 u24.x86_64 pigsty 710.2 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~noble_amd64.deb
postgresql-18-pg-graphql 1.6.3 u24.aarch64 pigsty 650.1 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~noble_arm64.deb
postgresql-18-pg-graphql 1.6.3 u26.x86_64 pigsty 709.1 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~resolute_amd64.deb
postgresql-18-pg-graphql 1.6.3 u26.aarch64 pigsty 648.4 KiB postgresql-18-pg-graphql_1.6.3-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_17 1.6.3 el8.x86_64 pigsty 752.9 KiB pg_graphql_17-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_17 1.6.3 el8.aarch64 pigsty 644.1 KiB pg_graphql_17-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_17 1.6.3 el9.x86_64 pigsty 752.4 KiB pg_graphql_17-1.6.3-1PGSTY.el9.x86_64.rpm
pg_graphql_17 1.6.3 el9.aarch64 pigsty 692.2 KiB pg_graphql_17-1.6.3-1PGSTY.el9.aarch64.rpm
pg_graphql_17 1.6.3 el10.x86_64 pigsty 752.3 KiB pg_graphql_17-1.6.3-1PGSTY.el10.x86_64.rpm
pg_graphql_17 1.6.3 el10.aarch64 pigsty 692.4 KiB pg_graphql_17-1.6.3-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-graphql 1.6.3 d12.x86_64 pigsty 660.7 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-graphql 1.6.3 d12.aarch64 pigsty 560.3 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-graphql 1.6.3 d13.x86_64 pigsty 660.6 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~trixie_amd64.deb
postgresql-17-pg-graphql 1.6.3 d13.aarch64 pigsty 560.2 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~trixie_arm64.deb
postgresql-17-pg-graphql 1.6.3 u22.x86_64 pigsty 714.5 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~jammy_amd64.deb
postgresql-17-pg-graphql 1.6.3 u22.aarch64 pigsty 656.3 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~jammy_arm64.deb
postgresql-17-pg-graphql 1.6.3 u24.x86_64 pigsty 710.1 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~noble_amd64.deb
postgresql-17-pg-graphql 1.6.3 u24.aarch64 pigsty 649.5 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~noble_arm64.deb
postgresql-17-pg-graphql 1.6.3 u26.x86_64 pigsty 709.1 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~resolute_amd64.deb
postgresql-17-pg-graphql 1.6.3 u26.aarch64 pigsty 648.6 KiB postgresql-17-pg-graphql_1.6.3-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_16 1.6.3 el8.x86_64 pigsty 752.9 KiB pg_graphql_16-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_16 1.6.3 el8.aarch64 pigsty 644.2 KiB pg_graphql_16-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_16 1.6.3 el9.x86_64 pigsty 752.3 KiB pg_graphql_16-1.6.3-1PGSTY.el9.x86_64.rpm
pg_graphql_16 1.6.3 el9.aarch64 pigsty 692.3 KiB pg_graphql_16-1.6.3-1PGSTY.el9.aarch64.rpm
pg_graphql_16 1.6.3 el10.x86_64 pigsty 752.4 KiB pg_graphql_16-1.6.3-1PGSTY.el10.x86_64.rpm
pg_graphql_16 1.6.3 el10.aarch64 pigsty 692.4 KiB pg_graphql_16-1.6.3-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-graphql 1.6.3 d12.x86_64 pigsty 660.3 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-graphql 1.6.3 d12.aarch64 pigsty 560.5 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-graphql 1.6.3 d13.x86_64 pigsty 660.2 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~trixie_amd64.deb
postgresql-16-pg-graphql 1.6.3 d13.aarch64 pigsty 560.3 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~trixie_arm64.deb
postgresql-16-pg-graphql 1.6.3 u22.x86_64 pigsty 714.4 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~jammy_amd64.deb
postgresql-16-pg-graphql 1.6.3 u22.aarch64 pigsty 656.6 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~jammy_arm64.deb
postgresql-16-pg-graphql 1.6.3 u24.x86_64 pigsty 710.0 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~noble_amd64.deb
postgresql-16-pg-graphql 1.6.3 u24.aarch64 pigsty 649.8 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~noble_arm64.deb
postgresql-16-pg-graphql 1.6.3 u26.x86_64 pigsty 708.9 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~resolute_amd64.deb
postgresql-16-pg-graphql 1.6.3 u26.aarch64 pigsty 648.7 KiB postgresql-16-pg-graphql_1.6.3-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_graphql_15 1.6.3 el8.x86_64 pigsty 752.9 KiB pg_graphql_15-1.6.3-1PGSTY.el8.x86_64.rpm
pg_graphql_15 1.6.3 el8.aarch64 pigsty 644.2 KiB pg_graphql_15-1.6.3-1PGSTY.el8.aarch64.rpm
pg_graphql_15 1.6.3 el9.x86_64 pigsty 752.6 KiB pg_graphql_15-1.6.3-1PGSTY.el9.x86_64.rpm
pg_graphql_15 1.6.3 el9.aarch64 pigsty 692.3 KiB pg_graphql_15-1.6.3-1PGSTY.el9.aarch64.rpm
pg_graphql_15 1.6.3 el10.x86_64 pigsty 752.7 KiB pg_graphql_15-1.6.3-1PGSTY.el10.x86_64.rpm
pg_graphql_15 1.6.3 el10.aarch64 pigsty 692.5 KiB pg_graphql_15-1.6.3-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-graphql 1.6.3 d12.x86_64 pigsty 660.5 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-graphql 1.6.3 d12.aarch64 pigsty 560.5 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-graphql 1.6.3 d13.x86_64 pigsty 660.2 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~trixie_amd64.deb
postgresql-15-pg-graphql 1.6.3 d13.aarch64 pigsty 560.3 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~trixie_arm64.deb
postgresql-15-pg-graphql 1.6.3 u22.x86_64 pigsty 714.5 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~jammy_amd64.deb
postgresql-15-pg-graphql 1.6.3 u22.aarch64 pigsty 656.3 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~jammy_arm64.deb
postgresql-15-pg-graphql 1.6.3 u24.x86_64 pigsty 710.1 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~noble_amd64.deb
postgresql-15-pg-graphql 1.6.3 u24.aarch64 pigsty 649.9 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~noble_arm64.deb
postgresql-15-pg-graphql 1.6.3 u26.x86_64 pigsty 709.1 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~resolute_amd64.deb
postgresql-15-pg-graphql 1.6.3 u26.aarch64 pigsty 648.6 KiB postgresql-15-pg-graphql_1.6.3-1PGSTY~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 via package name, for the active PG version

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.

表格阅读器