1+ import type { ObjMap } from '../jsutils/ObjMap' ;
12import { keyMap } from '../jsutils/keyMap' ;
23import { inspect } from '../jsutils/inspect' ;
34import { mapValue } from '../jsutils/mapValue' ;
@@ -48,10 +49,9 @@ import type {
4849 GraphQLNamedType ,
4950 GraphQLFieldConfig ,
5051 GraphQLFieldConfigMap ,
52+ GraphQLInputValueConfig ,
5153 GraphQLArgumentConfig ,
52- GraphQLFieldConfigArgumentMap ,
5354 GraphQLEnumValueConfigMap ,
54- GraphQLInputFieldConfigMap ,
5555} from '../type/definition' ;
5656import { assertSchema , GraphQLSchema } from '../type/schema' ;
5757import { specifiedScalarTypes , isSpecifiedScalarType } from '../type/scalars' ;
@@ -446,7 +446,7 @@ export function extendSchemaImpl(
446446 description : node . description ?. value ,
447447 locations,
448448 isRepeatable : node . repeatable ,
449- args : buildArgumentMap ( node . arguments ) ,
449+ args : buildInputValueMap ( node . arguments ) ,
450450 astNode : node ,
451451 } ) ;
452452 }
@@ -471,7 +471,7 @@ export function extendSchemaImpl(
471471 // with validateSchema() will produce more actionable results.
472472 type : ( getWrappedType ( field . type ) : any ) ,
473473 description : field . description ?. value ,
474- args : buildArgumentMap ( field . arguments ) ,
474+ args : buildInputValueMap ( field . arguments ) ,
475475 deprecationReason : getDeprecationReason ( field ) ,
476476 astNode : field ,
477477 } ;
@@ -480,54 +480,38 @@ export function extendSchemaImpl(
480480 return fieldConfigMap ;
481481 }
482482
483- function buildArgumentMap(
484- args: ?$ReadOnlyArray< InputValueDefinitionNode > ,
485- ): GraphQLFieldConfigArgumentMap {
483+ function buildInputValueMap(
484+ nodes: ?$ReadOnlyArray< InputValueDefinitionNode > ,
485+ configMap: ObjMap< GraphQLInputValueConfig > = Object.create(null),
486+ ): ObjMap< GraphQLInputValueConfig > {
486487 // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
487- const argsNodes = args ?? [ ] ;
488+ const inputNodes = nodes ?? [ ] ;
488489
489- const argConfigMap = Object . create ( null ) ;
490- for ( const arg of argsNodes ) {
490+ for ( const node of inputNodes ) {
491491 // Note: While this could make assertions to get the correctly typed
492492 // value, that would throw immediately while type system validation
493493 // with validateSchema() will produce more actionable results.
494- const type : any = getWrappedType ( arg . type ) ;
494+ const type : any = getWrappedType ( node . type ) ;
495495
496- argConfigMap [ arg . name . value ] = {
496+ configMap [ node . name . value ] = {
497497 type,
498- description : arg . description ?. value ,
499- defaultValue : valueFromAST ( arg . defaultValue , type ) ,
500- deprecationReason : getDeprecationReason ( arg ) ,
501- astNode : arg ,
498+ description : node . description ?. value ,
499+ defaultValue : valueFromAST ( node . defaultValue , type ) ,
500+ deprecationReason : getDeprecationReason ( node ) ,
501+ astNode : node ,
502502 } ;
503503 }
504- return argConfigMap ;
504+ return configMap ;
505505 }
506506
507507 function buildInputFieldMap(
508508 nodes: $ReadOnlyArray<
509509 InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode ,
510510 > ,
511- ): GraphQLInputFieldConfigMap {
512- const inputFieldMap = Object . create ( null ) ;
511+ ): ObjMap < GraphQLInputValueConfig > {
512+ let inputFieldMap = Object . create ( null ) ;
513513 for ( const node of nodes ) {
514- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
515- const fieldsNodes = node . fields ?? [ ] ;
516-
517- for ( const field of fieldsNodes ) {
518- // Note: While this could make assertions to get the correctly typed
519- // value, that would throw immediately while type system validation
520- // with validateSchema() will produce more actionable results.
521- const type : any = getWrappedType ( field . type ) ;
522-
523- inputFieldMap [ field . name . value ] = {
524- type,
525- description : field . description ?. value ,
526- defaultValue : valueFromAST ( field . defaultValue , type ) ,
527- deprecationReason : getDeprecationReason ( field ) ,
528- astNode : field ,
529- } ;
530- }
514+ inputFieldMap = buildInputValueMap ( node . fields , inputFieldMap ) ;
531515 }
532516 return inputFieldMap ;
533517 }
0 commit comments