Files
Utkarash Kumar SinghandJoshen Lim 08c0fc247b feat(studio): warn about pg_graphql introspection change on upgrade (#46096)
<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 -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](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>
2026-05-19 15:42:44 +01:00

194 lines
7.3 KiB
TypeScript

import { useParams } from 'common'
import Link from 'next/link'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns/admonition'
import { InlineLink } from '@/components/ui/InlineLink'
import {
ProjectUpgradeEligibilityValidationError,
ProjectUpgradeEligibilityWarning,
} from '@/data/config/project-upgrade-eligibility-query'
import { DOCS_URL } from '@/lib/constants'
export const ReadReplicasWarning = ({ latestPgVersion }: { latestPgVersion: string }) => {
const { ref } = useParams()
return (
<Admonition
type="note"
showIcon={false}
title="A newer version of Postgres is available"
description={`You will need to remove all read replicas prior to upgrading your Postgres version to the latest available (${latestPgVersion}).`}
actions={
<Button asChild type="default">
<Link href={`/project/${ref}/database/replication`}>Manage read replicas</Link>
</Button>
}
/>
)
}
const getValidationErrorTitle = (error: ProjectUpgradeEligibilityValidationError): string => {
switch (error.type) {
case 'objects_depending_on_pg_cron':
return (error.dependents ?? []).join(', ') || 'Objects depending on pg_cron'
case 'indexes_referencing_ll_to_earth':
return `${error.schema_name}.${error.index_name}`
case 'function_using_obsolete_lang':
return `${error.schema_name}.${error.function_name}`
case 'unsupported_extension':
return error.extension_name
case 'unsupported_fdw_handler':
return error.fdw_name
case 'unlogged_table_with_persistent_sequence':
return `${error.schema_name}.${error.table_name}`
case 'user_defined_objects_in_internal_schemas':
return `${error.schema_name}.${error.obj_name}`
case 'active_replication_slot':
return error.slot_name
}
}
const getValidationErrorDescription = (error: ProjectUpgradeEligibilityValidationError): string => {
switch (error.type) {
case 'objects_depending_on_pg_cron':
return 'Remove objects that depend on pg_cron'
case 'indexes_referencing_ll_to_earth':
return `Drop or recreate the index on table ${error.schema_name}.${error.table_name} that references ll_to_earth()`
case 'function_using_obsolete_lang':
return `Update the function to use a supported language instead of ${error.lang_name}`
case 'unsupported_extension':
return 'Remove the unsupported extension'
case 'unsupported_fdw_handler':
return `Update or remove the FDW using the obsolete handler ${error.fdw_handler_name}`
case 'unlogged_table_with_persistent_sequence':
return `Convert the sequence ${error.sequence_name} to unlogged or convert the table to logged`
case 'user_defined_objects_in_internal_schemas':
return `Move the ${error.obj_type} to your own schema`
case 'active_replication_slot':
return 'Drop the active replication slot'
}
}
const ValidationErrorItem = ({ error }: { error: ProjectUpgradeEligibilityValidationError }) => {
const { ref: projectRef } = useParams()
const title = getValidationErrorTitle(error)
const description = getValidationErrorDescription(error)
const getManageLink = (): string | null => {
const encode = encodeURIComponent
switch (error.type) {
case 'function_using_obsolete_lang':
return `/project/${projectRef}/database/functions?schema=${encode(error.schema_name)}&search=${encode(error.function_name)}`
case 'unsupported_extension':
return `/project/${projectRef}/database/extensions?filter=${encode(error.extension_name)}`
case 'indexes_referencing_ll_to_earth':
return `/project/${projectRef}/database/indexes?schema=${encode(error.schema_name)}&search=${encode(error.index_name)}`
case 'unlogged_table_with_persistent_sequence':
return `/project/${projectRef}/database/tables?schema=${encode(error.schema_name)}&search=${encode(error.table_name)}`
case 'user_defined_objects_in_internal_schemas':
if (error.obj_type === 'function') {
return `/project/${projectRef}/database/functions?schema=${encode(error.schema_name)}&search=${encode(error.obj_name)}`
}
if (error.obj_type === 'table') {
return `/project/${projectRef}/database/tables?schema=${encode(error.schema_name)}&search=${encode(error.obj_name)}`
}
return null
case 'active_replication_slot':
return null
case 'unsupported_fdw_handler':
return `/project/${projectRef}/integrations`
case 'objects_depending_on_pg_cron':
return null
default:
return null
}
}
const manageLink = getManageLink()
return (
<li className="py-3 last:pb-0 flex flex-row gap-x-3 justify-between items-center">
<div className="flex flex-col gap-y-0.5 flex-1 min-w-0">
<h6 className="overflow-hidden text-ellipsis whitespace-nowrap min-w-0 text-sm font-normal text-foreground">
{title}
</h6>
<p className="text-foreground-lighter text-xs">{description}</p>
</div>
{manageLink && (
<Button size="tiny" type="default" asChild>
<Link href={manageLink}>Manage</Link>
</Button>
)}
</li>
)
}
export const ValidationErrorsWarning = ({
validationErrors,
}: {
validationErrors: ProjectUpgradeEligibilityValidationError[]
}) => {
if (validationErrors.length === 0) return null
return (
<Admonition type="note" showIcon={false} title="A newer version of Postgres is available">
<div className="flex flex-col gap-3">
<p>
The following issues must be resolved before upgrading.{' '}
<InlineLink href={`${DOCS_URL}/guides/platform/upgrading`}>Learn more</InlineLink>
</p>
<ul className="border-t border-border-muted flex flex-col divide-y divide-border-muted">
{validationErrors.map((error, idx) => (
<ValidationErrorItem key={`${error.type}-${idx}`} error={error} />
))}
</ul>
</div>
</Admonition>
)
}
const getWarningTitle = (warning: ProjectUpgradeEligibilityWarning): string => {
switch (warning.type) {
case 'pg_graphql_introspection_change':
return 'GraphQL introspection will be disabled by default after upgrade'
}
}
const getWarningDescription = (warning: ProjectUpgradeEligibilityWarning): string => {
switch (warning.type) {
case 'pg_graphql_introspection_change':
return '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.'
}
}
const getWarningLink = (warning: ProjectUpgradeEligibilityWarning): string => {
switch (warning.type) {
case 'pg_graphql_introspection_change':
return `${DOCS_URL}/guides/platform/upgrading#upgrading-to-pg_graphql-160`
}
}
export const ValidationWarningsAdmonition = ({
warnings,
}: {
warnings: ProjectUpgradeEligibilityWarning[]
}) => {
if (warnings.length === 0) return null
return warnings.map((warning, idx) => (
<Admonition
key={`${warning.type}-${idx}`}
type="default"
title={getWarningTitle(warning)}
description={getWarningDescription(warning)}
>
<Button asChild type="default" className="mt-2">
<Link href={getWarningLink(warning)} target="_blank" rel="noreferrer">
Read upgrade notes
</Link>
</Button>
</Admonition>
))
}