What's New in pg_graphql v1.2
pg_graphql v1.1–1.2 now reflects views, materialized views and foreign tables into the GraphQL schema, with primary keys declared via a comment directive. Simple views also support inserts and updates, which can keep older API shapes working while the underlying tables are migrated. Filtering gains `is: NULL/NOT_NULL` on every scalar filter plus `like`, `ilike` and `startsWith` on strings; `startsWith` is preferred because it can use plain B-tree indexes. The release also implements the spec's `@skip`/`@include` directives and lets users set table and column descriptions through comment directives, and requires Postgres 15.1.0.63 or later.
Related posts
- pg_graphql: Postgres functions now supported
Supabase mediumAdeptpg_graphql 1.4+ reflects Postgres user-defined functions into the GraphQL schema, giving custom SQL logic a GraphQL entry point. Argument nullability follows from defaults, and function volatility decides placement: immutable and stable functions become Query fields, while volatile functions become Mutations. Functions returning setof a table type get Relay-style pagination, filtering, sorting and foreign-key relationships automatically. Overloaded, variadic, void-returning, nameless-argument, array-argument and tuple-argument functions are not yet supported.
- How pg_graphql works
Supabase mediumAdeptpg_graphql is a Rust-based Postgres extension that reflects the SQL schema as a GraphQL schema and serves queries through a `graphql.resolve` SQL function, with no separate server. A request is tokenized and parsed into an AST with the graphql-parser crate, then validated against the GraphQL spec using a reflected schema built from system catalogs. That schema is memoized and reloaded only when the search path, role or schema version changes. Validated queries become builder objects that emit SQL, with quote_ident/quote_literal guarding against injection, and the SQL returns jsonb that is passed back to the client as JSON.
- pg_graphql: A GraphQL extension for PostgreSQL
Supabase mediumAdeptpg_graphql is an open-source PostgreSQL extension, written in C and SQL, that reflects a GraphQL schema from existing tables and resolves queries entirely inside the database. Supabase built it because its 1 GB free-tier VMs had no memory left for a separate GraphQL process like Graphile or Hasura. Each GraphQL request is transpiled into a single SQL statement that aggregates results as JSON. This avoids N+1 queries, respects row level security, and gives multi-operation requests transactional semantics. Pagination follows the Relay connection spec using keyset pagination, the API is one SQL function (gql.resolve) exposed over HTTP via PostgREST, and a benchmark shows about 2,205 requests/second on a 4-core machine.
- pg_graphql 1.5.7: pagination and multi-tenancy support
Supabase mediumAdeptpg_graphql 1.5.7 adds offset-based pagination alongside existing keyset pagination, per-role schema caching for schema-per-tenant multi-tenancy, and array filter operators. Offset pagination maps to SQL LIMIT/OFFSET and gets slower as offsets grow, so keyset pagination remains the recommended approach. Since 1.5.2 the schema cache, keyed by Postgres role and schema version, loads only schemas the role has USAGE on. Tenants no longer all rebuild their caches when one tenant changes its schema, and this setup now serves a project with over 2,200 tenants. Since 1.5.6, contains, containedBy and overlaps filters work on scalar array columns such as text[].
- pg_graphql v1.0
Supabase mediumAdeptpg_graphql, a PostgreSQL extension that compiles GraphQL requests into a single SQL query, reaches 1.0 with a SemVer backwards-compatibility guarantee. Running inside Postgres instead of as a separate server keeps its memory footprint negligible on 1 GB Free Plan instances. That design also gives it Postgres roles and RLS for security, an always-in-sync schema with no N+1 queries, and ACID rollback across multi-mutation requests. The original pure-SQL transpiler hit limits near 4,000 lines because SQL functions pass by value and the planner stops inlining deeply nested calls, so it was rewritten in Rust with pgx. After the rewrite, overhead is under 300µs per request, about 1,060 queries/sec per connection from SQL, and about 645 req/s through the full HTTP and auth stack on Free Plan hardware.