Skip to content

fix: handle specifiedByURL field on __Type introspection#644

Open
shkuls wants to merge 2 commits into
supabase:masterfrom
shkuls:fix/specified-by-url
Open

fix: handle specifiedByURL field on __Type introspection#644
shkuls wants to merge 2 commits into
supabase:masterfrom
shkuls:fix/specified-by-url

Conversation

@shkuls

@shkuls shkuls commented Jun 29, 2026

Copy link
Copy Markdown

Problem

specifiedByURL is advertised as a field on __Type in the introspection schema, but querying it returns an error:

{"data": null, "errors": [{"message": "unexpected field specifiedByURL type on __Type"}]}

This breaks GraphQL clients that do 2-step introspection — they first ask what fields __Type supports, see specifiedByURL listed, then include it in their full introspection query and crash. Affected tools include Apollo Kotlin, graphql-codegen, and Rover CLI.

Reported in:

Root cause

Three systems were out of sync:

  1. src/graphql.rs__TypeType::fields() advertised specifiedByURL
  2. src/builder.rs__TypeField enum had no SpecifiedByURL variant, and the query parser's match fell through to the _ => Err(...) catch-all ✗
  3. src/transpile.rs__TypeBuilder::serialize() had no arm to write the field ✗

Fix

Three small additive changes:

  • Add specified_by_url() -> Option<String> to the ___Type trait with a default of None
  • Add SpecifiedByURL variant to the __TypeField enum
  • Add "specifiedByURL" => __TypeField::SpecifiedByURL match arm in the query builder
  • Add serializer arm that calls self.type_.specified_by_url() (returns null for all current types)

No existing behaviour changes. All types correctly return null since pg_graphql has no custom scalars with a specification URL.

Test

Added test/sql/resolve_specified_by_url.sql covering:

  • specifiedByURL on a built-in scalar (Boolean) returns null
  • specifiedByURL alongside other fields (String) returns null
  • specifiedByURL on a non-scalar type (Query) returns null

Repro (before fix)

# Step 1: specifiedByURL is advertised
curl -s -X POST http://localhost:54321/graphql/v1 \
  -H "Content-Type: application/json" \
  -d '{"query":"{ __schema { types { name fields { name } } } }"}' \
  | grep specifiedByURL   # → found

# Step 2: querying it crashes
curl -s -X POST http://localhost:54321/graphql/v1 \
  -H "Content-Type: application/json" \
  -d '{"query":"{ __type(name: \"Boolean\") { specifiedByURL } }"}'
# → {"data": null, "errors": [{"message": "unexpected field specifiedByURL type on __Type"}]}

shkuls added 2 commits June 29, 2026 16:33
The ___Type trait, __TypeField enum, query builder, and serializer all
lacked support for specifiedByURL despite it being advertised in the
schema. This caused GraphQL clients that do 2-step introspection (e.g.
Apollo Kotlin, graphql-codegen) to fail with "unexpected field
specifiedByURL type on __Type" when they queried the field after
discovering it in the pre-introspection response.

Fixes supabase/supabase#31158
Fixes supabase#629
Verifies that specifiedByURL is queryable and returns null for built-in
scalar types and object types, matching the GraphQL Oct 2021 spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant