mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
<img width="1512" height="818" alt="introspection" src="https://github.com/user-attachments/assets/5c0e4c6a-c0e9-496d-8768-4a55a2433268" /> ## Summary Adds an in-product admonition on the Infrastructure Settings page when a project has pg_graphql < 1.6.0 installed, warning users that GraphQL introspection will be disabled by default after upgrading. Links to upgrade notes docs with the opt-in SQL. The admonition is purely informational — it renders alongside the upgrade button, does not block the upgrade. ## Context pg_graphql 1.6.0 disables GraphQL introspection by default. The change is upgrade-triggered (not backported), so users on 1.5.x will only encounter it when their AMI bundles 1.6.0+. To prevent surprise breakage of tools that rely on `__schema`/`__type` (GraphiQL, codegen, Relay compiler, etc.), Studio surfaces this admonition before they upgrade. Design discussion in [PSQL-1199](https://linear.app/supabase/issue/PSQL-1199/prepare-dashboard-notification-for-pg-graphql-breaking-change). ## Companion PR This depends on the schema change in [supabase/platform#32954](https://github.com/supabase/platform/pull/32954) which adds the new `warnings` field to `ProjectUpgradeEligibilityResponse`. ## Admonition copy - **Title:** \"GraphQL introspection will be disabled by default after upgrade\" - **Body:** \"After upgrading, queries to \`__schema\` and \`__type\` will return an error unless introspection is explicitly re-enabled on the schema. Regular data queries are not affected.\" - **CTA:** \"Read upgrade notes\" → links to the new docs section ## Related - Linear: [PSQL-1199](https://linear.app/supabase/issue/PSQL-1199/prepare-dashboard-notification-for-pg-graphql-breaking-change) - Parent rollout: [PSQL-1163](https://linear.app/supabase/issue/PSQL-1163/breaking-change-pg-graphql-introspection-rollout) - Companion platform PR: https://github.com/supabase/platform/pull/32954 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added “Upgrading to pg_graphql 1.6.0” and updated pg_graphql docs: introspection is disabled by default, how to re-enable per schema, verification steps, and affected tools. * **New Features** * Upgrade settings UI now shows validation warnings about introspection with links to upgrade notes. * **Chores** * Added "GraphiQL" to MDX spelling allow list and added upgrade-warning types to API surface. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46096?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
118 lines
3.1 KiB
Plaintext
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)
|