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