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
|
Source
pig build pkg pg_graphql; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall 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 14Create this extension with:
CREATE EXTENSION pg_graphql;Usage
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
Querytype - 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