1+ import type { ObjMap } from '../jsutils/ObjMap' ;
12import { keyMap } from '../jsutils/keyMap' ;
23import { inspect } from '../jsutils/inspect' ;
34import { mapValue } from '../jsutils/mapValue' ;
@@ -47,10 +48,9 @@ import type {
4748 GraphQLNamedType ,
4849 GraphQLFieldConfig ,
4950 GraphQLFieldConfigMap ,
51+ GraphQLInputValueConfig ,
5052 GraphQLArgumentConfig ,
51- GraphQLFieldConfigArgumentMap ,
5253 GraphQLEnumValueConfigMap ,
53- GraphQLInputFieldConfigMap ,
5454} from '../type/definition' ;
5555import { assertSchema , GraphQLSchema } from '../type/schema' ;
5656import { specifiedScalarTypes , isSpecifiedScalarType } from '../type/scalars' ;
@@ -444,7 +444,7 @@ export function extendSchemaImpl(
444444 // $FlowFixMe[incompatible-call]
445445 locations : node . locations . map ( ( { value } ) => value ) ,
446446 isRepeatable : node . repeatable ,
447- args : buildArgumentMap ( node . arguments ) ,
447+ args : buildInputValueMap ( node . arguments ) ,
448448 astNode : node ,
449449 } ) ;
450450 }
@@ -469,7 +469,7 @@ export function extendSchemaImpl(
469469 // with validateSchema() will produce more actionable results.
470470 type : getWrappedType ( field . type ) ,
471471 description : field . description ?. value ,
472- args : buildArgumentMap ( field . arguments ) ,
472+ args : buildInputValueMap ( field . arguments ) ,
473473 deprecationReason : getDeprecationReason ( field ) ,
474474 astNode : field ,
475475 } ;
@@ -478,54 +478,38 @@ export function extendSchemaImpl(
478478 return fieldConfigMap ;
479479 }
480480
481- function buildArgumentMap (
482- args : ?$ReadOnlyArray < InputValueDefinitionNode > ,
483- ): GraphQLFieldConfigArgumentMap {
481+ function buildInputValueMap (
482+ nodes : ?$ReadOnlyArray < InputValueDefinitionNode > ,
483+ configMap: ObjMap< GraphQLInputValueConfig > = Object.create(null),
484+ ): ObjMap< GraphQLInputValueConfig > {
484485 // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
485- const argsNodes = args ?? [ ] ;
486+ const inputNodes = nodes ?? [ ] ;
486487
487- const argConfigMap = Object . create ( null ) ;
488- for ( const arg of argsNodes ) {
488+ for ( const node of inputNodes ) {
489489 // Note: While this could make assertions to get the correctly typed
490490 // value, that would throw immediately while type system validation
491491 // with validateSchema() will produce more actionable results.
492- const type : any = getWrappedType ( arg . type ) ;
492+ const type : any = getWrappedType ( node . type ) ;
493493
494- argConfigMap [ arg . name . value ] = {
494+ configMap [ node . name . value ] = {
495495 type,
496- description : arg . description ?. value ,
497- defaultValue : valueFromAST ( arg . defaultValue , type ) ,
498- deprecationReason : getDeprecationReason ( arg ) ,
499- astNode : arg ,
496+ description : node . description ?. value ,
497+ defaultValue : valueFromAST ( node . defaultValue , type ) ,
498+ deprecationReason : getDeprecationReason ( node ) ,
499+ astNode : node ,
500500 } ;
501501 }
502- return argConfigMap ;
502+ return configMap ;
503503 }
504504
505505 function buildInputFieldMap(
506506 nodes: $ReadOnlyArray<
507507 InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode ,
508508 > ,
509- ): GraphQLInputFieldConfigMap {
510- const inputFieldMap = Object . create ( null ) ;
509+ ): ObjMap < GraphQLInputValueConfig > {
510+ let inputFieldMap = Object . create ( null ) ;
511511 for ( const node of nodes ) {
512- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
513- const fieldsNodes = node . fields ?? [ ] ;
514-
515- for ( const field of fieldsNodes ) {
516- // Note: While this could make assertions to get the correctly typed
517- // value, that would throw immediately while type system validation
518- // with validateSchema() will produce more actionable results.
519- const type : any = getWrappedType ( field . type ) ;
520-
521- inputFieldMap [ field . name . value ] = {
522- type,
523- description : field . description ?. value ,
524- defaultValue : valueFromAST ( field . defaultValue , type ) ,
525- deprecationReason : getDeprecationReason ( field ) ,
526- astNode : field ,
527- } ;
528- }
512+ inputFieldMap = buildInputValueMap ( node . fields , inputFieldMap ) ;
529513 }
530514 return inputFieldMap ;
531515 }
0 commit comments