Files
supabase/apps/docs/content/guides/database/extensions/pg_graphql.mdx
T
Kimaswa Emmanuel YusufuandChris Chinchilla d35e8081d0 docs: fix invalid syntax and wrong identifiers in code examples (#46694)
Reading through the guides and troubleshooting docs I found a set of
code examples that don't parse or run as written. Each is a small,
self-contained fix:

- **troubleshooting/postgres-logs**: the `regexp_contains(...)` call was
missing its closing parenthesis.
- **troubleshooting/rls-performance**: the PL/pgSQL `return` statement
was missing its terminating semicolon.
- **troubleshooting/supavisor-faq**: the `CREATE USER ... WITH PASSWORD`
string literal was unterminated (missing closing quote).
- **troubleshooting/google-auth-fails**: missing comma between
`provider` and `options` in the `signInWithOAuth` object literal.
- **integrations/supabase-for-platforms**,
**database/extensions/pg_graphql**,
**deployment/branching/working-with-branches**: missing commas between
JSON properties.
- **database/extensions/pgjwt**: the default algorithm was written
`'HSA256'`; the real default is `'HS256'` (used in both `sign` and
`verify`).
- **auth/auth-email-passwordless** (Dart): `signinwithotp` should be
`signInWithOtp`.
- **auth/third-party/firebase-auth**: `async function
setRoleCustomClaim() => {` mixed a function declaration with arrow
syntax.
- **storage/management/copy-move-objects**: the storage helper is
`storage.foldername(name)`, not `storage.folder(name)`.
- **troubleshooting/hsnw-index**: prose referred to
`maintance_work_mem`; the setting is `maintenance_work_mem` (the SQL in
the same file spells it correctly).
- **troubleshooting/pgcron-debugging**: a stray double quote inside the
`cron.job_run_details` code span.

13 files, all one-line fixes. Happy to split if you'd prefer.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Corrected code examples across authentication, database, storage, and
troubleshooting guides
* Fixed method naming and syntax errors in code snippets (Dart auth,
Node.js Firebase, SQL functions)
  * Updated API signatures and variable names for accuracy
  * Improved JSON formatting in example payloads
  * Corrected typos in documentation text

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
2026-06-08 15:09:08 +00:00

118 lines
3.1 KiB
Plaintext

---
id: 'pg_graphql'
title: 'pg_graphql: GraphQL for Postgres'
description: 'A GraphQL Interface for Postgres'
---
[pg_graphql](https://supabase.github.io/pg_graphql/) is Postgres extension for interacting with the database using [GraphQL](https://graphql.org) instead of SQL.
The extension reflects a GraphQL schema from the existing SQL schema and exposes it through a SQL function, `graphql.resolve(...)`. This enables any programming language that can connect to Postgres to query the database via GraphQL with no additional servers, processes, or libraries.
The `pg_graphql` resolve method is designed to interop with [PostgREST](https://postgrest.org/en/stable/index.html), the tool that underpins the Supabase API, such that the `graphql.resolve` function can be called via RPC to safely and performantly expose the GraphQL API over HTTP/S.
For more information about how the SQL schema is reflected into a GraphQL schema, see the [pg_graphql API docs](https://supabase.github.io/pg_graphql/api/).
## Enable the extension
<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="dashboard"
queryGroup="database-method"
>
<TabPanel id="dashboard" label="Dashboard">
1. Go to the [Database](/dashboard/project/_/database/tables) page in the Dashboard.
2. Click on **Extensions** in the sidebar.
3. Search for "pg_graphql" and enable the extension.
</TabPanel>
<TabPanel id="sql" label="SQL">
{/* prettier-ignore */}
```sql
-- Enable the "pg_graphql" extension
create extension pg_graphql;
-- Disable the "pg_graphql" extension
drop extension if exists pg_graphql;
```
Even though the SQL code is `create extension`, this is the equivalent of "enabling the extension".
To disable an extension you can call `drop extension`.
</TabPanel>
</Tabs>
## Usage
Given a table
{/* prettier-ignore */}
```sql
create table "Blog"(
id serial primary key,
name text not null,
description text
);
insert into "Blog"(name)
values ('My Blog');
```
The reflected GraphQL schema can be queried immediately as
{/* prettier-ignore */}
```sql
select
graphql.resolve($$
{
blogCollection(first: 1) {
edges {
node {
id,
name
}
}
}
}
$$);
```
returning the JSON
{/* prettier-ignore */}
```json
{
"data": {
"blogCollection": {
"edges": [
{
"node": {
"id": 1,
"name": "My Blog"
}
}
]
}
}
}
```
Note that `pg_graphql` supports schema introspection, so you can connect any GraphQL IDE or schema inspection tool to see the full set of fields and arguments available in the API. Starting from `pg_graphql` 1.6.0, introspection is **disabled by default** and must be enabled per schema:
```sql
comment on schema public is e'@graphql({"introspection": true})';
```
See the [upgrade notes](/guides/platform/upgrading#upgrading-to-pg_graphql-160) for details.
## API
- [`graphql.resolve`](https://supabase.github.io/pg_graphql/sql_interface/): A SQL function for executing GraphQL queries.
## Resources
- Official [`pg_graphql` documentation](https://github.com/supabase/pg_graphql)