1
+ import type { ObjMap } from '../jsutils/ObjMap' ;
1
2
import { keyMap } from '../jsutils/keyMap' ;
2
3
import { inspect } from '../jsutils/inspect' ;
3
4
import { mapValue } from '../jsutils/mapValue' ;
@@ -48,10 +49,9 @@ import type {
48
49
GraphQLNamedType ,
49
50
GraphQLFieldConfig ,
50
51
GraphQLFieldConfigMap ,
52
+ GraphQLInputValueConfig ,
51
53
GraphQLArgumentConfig ,
52
- GraphQLFieldConfigArgumentMap ,
53
54
GraphQLEnumValueConfigMap ,
54
- GraphQLInputFieldConfigMap ,
55
55
} from '../type/definition' ;
56
56
import { assertSchema , GraphQLSchema } from '../type/schema' ;
57
57
import { specifiedScalarTypes , isSpecifiedScalarType } from '../type/scalars' ;
@@ -446,7 +446,7 @@ export function extendSchemaImpl(
446
446
description : node . description ?. value ,
447
447
locations,
448
448
isRepeatable : node . repeatable ,
449
- args : buildArgumentMap ( node . arguments ) ,
449
+ args : buildInputValueMap ( node . arguments ) ,
450
450
astNode : node ,
451
451
} ) ;
452
452
}
@@ -471,7 +471,7 @@ export function extendSchemaImpl(
471
471
// with validateSchema() will produce more actionable results.
472
472
type : ( getWrappedType ( field . type ) : any ) ,
473
473
description : field . description ?. value ,
474
- args : buildArgumentMap ( field . arguments ) ,
474
+ args : buildInputValueMap ( field . arguments ) ,
475
475
deprecationReason : getDeprecationReason ( field ) ,
476
476
astNode : field ,
477
477
} ;
@@ -480,54 +480,38 @@ export function extendSchemaImpl(
480
480
return fieldConfigMap ;
481
481
}
482
482
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 > {
486
487
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
487
- const argsNodes = args ?? [ ] ;
488
+ const inputNodes = nodes ?? [ ] ;
488
489
489
- const argConfigMap = Object . create ( null ) ;
490
- for ( const arg of argsNodes ) {
490
+ for ( const node of inputNodes ) {
491
491
// Note: While this could make assertions to get the correctly typed
492
492
// value, that would throw immediately while type system validation
493
493
// with validateSchema() will produce more actionable results.
494
- const type : any = getWrappedType ( arg . type ) ;
494
+ const type : any = getWrappedType ( node . type ) ;
495
495
496
- argConfigMap [ arg . name . value ] = {
496
+ configMap [ node . name . value ] = {
497
497
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 ,
502
502
} ;
503
503
}
504
- return argConfigMap ;
504
+ return configMap ;
505
505
}
506
506
507
507
function buildInputFieldMap(
508
508
nodes: $ReadOnlyArray<
509
509
InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode ,
510
510
> ,
511
- ): GraphQLInputFieldConfigMap {
512
- const inputFieldMap = Object . create ( null ) ;
511
+ ): ObjMap < GraphQLInputValueConfig > {
512
+ let inputFieldMap = Object . create ( null ) ;
513
513
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 ) ;
531
515
}
532
516
return inputFieldMap ;
533
517
}
0 commit comments