@@ -955,6 +955,45 @@ describe('runTypes integration', () => {
955955 }
956956 } )
957957
958+ // Regression: TYPE_KINDS never included 'graphql_extend'. languages/graphql_idx.ts's TYPE_RE
959+ // handler maps EVERY `extend type|interface|input|enum|union|scalar Foo { ... }` declaration
960+ // (GraphQL's mechanism for adding fields to a type from another file/module, ubiquitous in
961+ // federation and schema-stitching) to this one shared kind regardless of which keyword follows
962+ // `extend` -- but unlike the six non-extend KIND_MAP entries above (all already fixed), this
963+ // kind was never added to TYPE_KINDS, so every `extend` declaration was indexed but silently
964+ // excluded from `token-goat types` in its entirety -- the same class of gap already fixed for
965+ // the other six GraphQL kinds, Rust union, Swift protocol/actor, Zig opaque, Dart mixin/
966+ // extension, proto message/enum/service, Apex class/interface/enum, and Kotlin/Scala 'object'.
967+ it ( "surfaces GraphQL 'extend' declarations via TYPE_KINDS, matching the other GraphQL kinds" , ( ) => {
968+ const dir = mkdtempSync ( join ( process . cwd ( ) , 'tg-types-graphql-extend-' ) )
969+ try {
970+ const file = join ( dir , 'fixture.graphql' )
971+ writeFileSync (
972+ file ,
973+ [ 'extend type TypesGraphqlExtendFixture {' , ' extraField: String' , '}' , '' ] . join ( '\n' ) ,
974+ )
975+ indexFileSync ( normalizePath ( file ) )
976+
977+ let captured = ''
978+ const origWrite = process . stdout . write . bind ( process . stdout )
979+ process . stdout . write = ( chunk : string | Uint8Array , ...rest : unknown [ ] ) : boolean => {
980+ if ( typeof chunk === 'string' ) captured += chunk
981+ return origWrite ( chunk , ...( rest as Parameters < typeof origWrite > ) )
982+ }
983+ try {
984+ const code = runTypes ( { file : normalizePath ( file ) , json : true } )
985+ expect ( code ) . toBe ( 0 )
986+ } finally {
987+ process . stdout . write = origWrite
988+ }
989+ const parsed = JSON . parse ( captured ) as Array < { name : string ; kind : string } >
990+ expect ( parsed . map ( ( r ) => r . name ) ) . toContain ( 'TypesGraphqlExtendFixture' )
991+ expect ( parsed . find ( ( r ) => r . name === 'TypesGraphqlExtendFixture' ) ?. kind ) . toBe ( 'graphql_extend' )
992+ } finally {
993+ rmSync ( dir , { recursive : true , force : true } )
994+ }
995+ } )
996+
958997 // Regression: TYPE_KINDS never included 'sfc_script_class'. languages/sfc_idx.ts (Vue/Svelte/
959998 // Astro single-file components) emits this distinct kind for a top-level `class Foo { ... }`
960999 // declaration in a component's script block rather than the generic 'class', so unlike a plain
0 commit comments