@@ -244,10 +244,6 @@ export class ASTDefinitionBuilder {
244
244
) ;
245
245
}
246
246
247
- buildTypes ( nodes : $ReadOnlyArray < NamedTypeNode > ) : Array < GraphQLNamedType > {
248
- return nodes . map ( node => this . buildType ( node ) ) ;
249
- }
250
-
251
247
buildType ( node : NamedTypeNode | TypeDefinitionNode ) : GraphQLNamedType {
252
248
const typeName = node . name . value ;
253
249
if ( ! this . _cache [ typeName ] ) {
@@ -345,15 +341,17 @@ export class ASTDefinitionBuilder {
345
341
}
346
342
347
343
_makeTypeDef ( def : ObjectTypeDefinitionNode ) {
348
- const interfaces = def . interfaces ;
344
+ const interfaces : ? $ReadOnlyArray < NamedTypeNode > = def.interfaces;
349
345
return new GraphQLObjectType({
350
346
name : def . name . value ,
351
347
description : getDescription ( def , this . _options ) ,
352
348
fields : ( ) => this . _makeFieldDefMap ( def ) ,
353
349
// Note: While this could make early assertions to get the correctly
354
350
// typed values, that would throw immediately while type system
355
351
// validation with validateSchema() will produce more actionable results.
356
- interfaces : interfaces ? ( ) => ( this . buildTypes ( interfaces ) : any ) : [ ] ,
352
+ interfaces : interfaces
353
+ ? ( ) => interfaces . map ( ref => ( this . buildType ( ref ) : any ) )
354
+ : [ ] ,
357
355
astNode : def ,
358
356
} );
359
357
}
@@ -407,13 +405,14 @@ export class ASTDefinitionBuilder {
407
405
}
408
406
409
407
_makeUnionDef(def: UnionTypeDefinitionNode) {
408
+ const types : ?$ReadOnlyArray < NamedTypeNode > = def . types ;
410
409
return new GraphQLUnionType ( {
411
410
name : def . name . value ,
412
411
description : getDescription ( def , this . _options ) ,
413
412
// Note: While this could make assertions to get the correctly typed
414
413
// values below, that would throw immediately while type system
415
414
// validation with validateSchema() will produce more actionable results.
416
- types : def . types ? ( this . buildTypes ( def . types ) : any ) : [ ] ,
415
+ types : types ? ( ) => types . map ( ref => ( this . buildType ( ref ) : any ) ) : [ ] ,
417
416
astNode : def ,
418
417
} ) ;
419
418
}
0 commit comments