← Browse the extensions catalog

pg-graphql

Source README ↗

pg_graphql

pg_graphql adds GraphQL support to PostgreSQL. It reflects the SQL schema and exposes it through the graphql.resolve(...) SQL function, so clients can query the database with GraphQL without a separate application server. This image supports PostgreSQL 18 on Debian bookworm and trixie.

Follow the quick start to set up extension-update email alerts first, then use the CronJob to install and refresh the catalog. These examples inherit image references and runtime settings from the catalog. The Cluster YAML is an excerpt: replace imageCatalogRef: ... with your catalog reference and keep your existing instance and storage settings.

Usage

1. Add the pg-graphql extension image to your Cluster

Define the pg-graphql extension under the postgresql.extensions section of your Cluster resource. For example:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cluster-pg-graphql
spec:
  imageCatalogRef: ...
  postgresql:
    extensions:
    - name: pg-graphql

2. Enable the extension in a database

Once the extension's files are available in the cluster, you can install it in a database in either of two ways:

Platform teams may make extension containers available across their clusters without installing every extension in every database. Install only the extensions a database uses; letting users enable them through SQL alongside the rest of their DDL schema management code can be a convenient approach.

For extensions that normally require superuser privileges, platform teams can use pgextwlist to allow non-superusers to install an administrator-approved selection of extensions.

3. Verify installation

Once the database is ready, connect to it with psql and run:

\dx

You should see pg_graphql listed among the installed extensions.

Known Caveats

GraphQL introspection is disabled by default from pg_graphql 1.6.0 onward. To enable schema exploration tools for a schema, add the upstream directive, for example:

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

See the upstream configuration guide for the available schema directives.

Extension and dependency licenses and copyright notices are bundled in /licenses/ in the image.