fix: handle specifiedByURL field on __Type introspection#644
Open
shkuls wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
specifiedByURLis advertised as a field on__Typein the introspection schema, but querying it returns an error:This breaks GraphQL clients that do 2-step introspection — they first ask what fields
__Typesupports, seespecifiedByURLlisted, 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:
src/graphql.rs—__TypeType::fields()advertisedspecifiedByURL✓src/builder.rs—__TypeFieldenum had noSpecifiedByURLvariant, and the query parser's match fell through to the_ => Err(...)catch-all ✗src/transpile.rs—__TypeBuilder::serialize()had no arm to write the field ✗Fix
Three small additive changes:
specified_by_url() -> Option<String>to the___Typetrait with a default ofNoneSpecifiedByURLvariant to the__TypeFieldenum"specifiedByURL" => __TypeField::SpecifiedByURLmatch arm in the query builderself.type_.specified_by_url()(returnsnullfor all current types)No existing behaviour changes. All types correctly return
nullsince pg_graphql has no custom scalars with a specification URL.Test
Added
test/sql/resolve_specified_by_url.sqlcovering:specifiedByURLon a built-in scalar (Boolean) returnsnullspecifiedByURLalongside other fields (String) returnsnullspecifiedByURLon a non-scalar type (Query) returnsnullRepro (before fix)