@@ -13,6 +13,7 @@ import isNullish from '../jsutils/isNullish';
13
13
import { ENUM } from '../language/kinds' ;
14
14
import { assertValidName } from '../utilities/assertValidName' ;
15
15
import type {
16
+ ASTNode ,
16
17
OperationDefinitionNode ,
17
18
FieldNode ,
18
19
FragmentDefinitionNode ,
@@ -294,13 +295,15 @@ function resolveThunk<T>(thunk: Thunk<T>): T {
294
295
export class GraphQLScalarType {
295
296
name : string ;
296
297
description : ?string ;
298
+ astNode : ?ASTNode ;
297
299
298
300
_scalarConfig : GraphQLScalarTypeConfig < * , * > ;
299
301
300
302
constructor ( config : GraphQLScalarTypeConfig < * , * > ) : void {
301
303
assertValidName ( config . name ) ;
302
304
this . name = config . name ;
303
305
this . description = config . description ;
306
+ this . astNode = config . astNode || null ;
304
307
invariant (
305
308
typeof config . serialize === 'function' ,
306
309
`${ this . name } must provide "serialize" function. If this custom Scalar ` +
@@ -364,6 +367,7 @@ GraphQLScalarType.prototype.toJSON =
364
367
export type GraphQLScalarTypeConfig < TInternal , TExternal > = {
365
368
name : string ;
366
369
description ?: ?string ;
370
+ astNode ?: ?ASTNode ;
367
371
serialize : ( value : mixed ) => ?TExternal ;
368
372
parseValue ?: ( value : mixed ) => ?TInternal ;
369
373
parseLiteral ?: ( valueNode : ValueNode ) => ?TInternal ;
@@ -411,6 +415,8 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {
411
415
export class GraphQLObjectType {
412
416
name : string ;
413
417
description : ?string ;
418
+ astNode : ?ASTNode ;
419
+ extensionASTNodes : Array < ASTNode > ;
414
420
isTypeOf : ?GraphQLIsTypeOfFn < * , * > ;
415
421
416
422
_typeConfig : GraphQLObjectTypeConfig < * , * > ;
@@ -421,6 +427,8 @@ export class GraphQLObjectType {
421
427
assertValidName ( config . name , config . isIntrospection ) ;
422
428
this . name = config . name ;
423
429
this . description = config . description ;
430
+ this . astNode = config . astNode || null ;
431
+ this . extensionASTNodes = config . extensionASTNodes || [ ] ;
424
432
if ( config . isTypeOf ) {
425
433
invariant (
426
434
typeof config . isTypeOf === 'function' ,
@@ -562,7 +570,8 @@ function defineFieldMap<TSource, TContext>(
562
570
name : argName ,
563
571
description : arg . description === undefined ? null : arg . description ,
564
572
type : arg . type ,
565
- defaultValue : arg . defaultValue
573
+ defaultValue : arg . defaultValue ,
574
+ astNode : arg . astNode ,
566
575
} ;
567
576
} ) ;
568
577
}
@@ -587,6 +596,8 @@ export type GraphQLObjectTypeConfig<TSource, TContext> = {
587
596
isTypeOf ?: ?GraphQLIsTypeOfFn < TSource , TContext > ;
588
597
description ?: ?string ;
589
598
isIntrospection ?: boolean ;
599
+ astNode ?: ?ASTNode ;
600
+ extensionASTNodes ?: ?Array < ASTNode > ;
590
601
} ;
591
602
592
603
export type GraphQLTypeResolver < TSource , TContext > = (
@@ -630,6 +641,7 @@ export type GraphQLFieldConfig<TSource, TContext> = {
630
641
subscribe ?: GraphQLFieldResolver < TSource , TContext > ;
631
642
deprecationReason ?: ?string ;
632
643
description ?: ?string ;
644
+ astNode ?: ?ASTNode ;
633
645
} ;
634
646
635
647
export type GraphQLFieldConfigArgumentMap = {
@@ -640,6 +652,7 @@ export type GraphQLArgumentConfig = {
640
652
type : GraphQLInputType ;
641
653
defaultValue ?: mixed ;
642
654
description ?: ?string ;
655
+ astNode ?: ?ASTNode ;
643
656
} ;
644
657
645
658
export type GraphQLFieldConfigMap < TSource , TContext > = {
@@ -655,13 +668,15 @@ export type GraphQLField<TSource, TContext> = {
655
668
subscribe ?: GraphQLFieldResolver < TSource , TContext > ;
656
669
isDeprecated ?: boolean ;
657
670
deprecationReason ?: ?string ;
671
+ astNode ?: ?ASTNode ;
658
672
} ;
659
673
660
674
export type GraphQLArgument = {
661
675
name : string ;
662
676
type : GraphQLInputType ;
663
677
defaultValue ?: mixed ;
664
678
description ?: ?string ;
679
+ astNode ?: ?ASTNode ;
665
680
} ;
666
681
667
682
export type GraphQLFieldMap < TSource , TContext > = {
@@ -691,6 +706,7 @@ export type GraphQLFieldMap<TSource, TContext> = {
691
706
export class GraphQLInterfaceType {
692
707
name : string ;
693
708
description : ?string ;
709
+ astNode : ?ASTNode ;
694
710
resolveType : ?GraphQLTypeResolver < * , * > ;
695
711
696
712
_typeConfig : GraphQLInterfaceTypeConfig < * , * > ;
@@ -700,6 +716,7 @@ export class GraphQLInterfaceType {
700
716
assertValidName ( config . name ) ;
701
717
this . name = config . name ;
702
718
this . description = config . description ;
719
+ this . astNode = config . astNode || null ;
703
720
if ( config . resolveType ) {
704
721
invariant (
705
722
typeof config . resolveType === 'function' ,
@@ -737,7 +754,8 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
737
754
* Object type.
738
755
*/
739
756
resolveType ?: ?GraphQLTypeResolver < TSource , TContext> ,
740
- description ?: ?string
757
+ description ?: ?string ,
758
+ astNode ?: ?ASTNode ,
741
759
} ;
742
760
743
761
@@ -768,6 +786,7 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
768
786
export class GraphQLUnionType {
769
787
name : string ;
770
788
description : ?string ;
789
+ astNode : ?ASTNode ;
771
790
resolveType : ?GraphQLTypeResolver < * , * > ;
772
791
773
792
_typeConfig : GraphQLUnionTypeConfig < * , * > ;
@@ -778,6 +797,7 @@ export class GraphQLUnionType {
778
797
assertValidName ( config . name ) ;
779
798
this . name = config . name ;
780
799
this . description = config . description ;
800
+ this . astNode = config . astNode || null ;
781
801
if ( config . resolveType ) {
782
802
invariant (
783
803
typeof config . resolveType === 'function' ,
@@ -854,6 +874,7 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {
854
874
*/
855
875
resolveType ?: ?GraphQLTypeResolver < TSource , TContext > ;
856
876
description ?: ?string ;
877
+ astNode ?: ?ASTNode ;
857
878
} ;
858
879
859
880
@@ -882,6 +903,7 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {
882
903
export class GraphQLEnumType /* <T> */ {
883
904
name : string ;
884
905
description : ?string ;
906
+ astNode : ?ASTNode ;
885
907
886
908
_enumConfig : GraphQLEnumTypeConfig /* <T> */ ;
887
909
_values : Array < GraphQLEnumValue /* <T> */ > ;
@@ -892,6 +914,7 @@ export class GraphQLEnumType/* <T> */ {
892
914
this. name = config . name ;
893
915
assertValidName ( config . name , config . isIntrospection ) ;
894
916
this . description = config . description ;
917
+ this . astNode = config . astNode || null ;
895
918
this . _values = defineEnumValues ( this , config . values ) ;
896
919
this . _enumConfig = config ;
897
920
}
@@ -1008,6 +1031,7 @@ function defineEnumValues(
1008
1031
description : value . description ,
1009
1032
isDeprecated : Boolean ( value . deprecationReason ) ,
1010
1033
deprecationReason : value . deprecationReason ,
1034
+ astNode : value . astNode || null ,
1011
1035
value : value . hasOwnProperty ( 'value' ) ? value . value : valueName ,
1012
1036
} ;
1013
1037
} ) ;
@@ -1017,6 +1041,7 @@ export type GraphQLEnumTypeConfig/* <T> */ = {
1017
1041
name : string ;
1018
1042
values : GraphQLEnumValueConfigMap /* <T> */ ;
1019
1043
description ?: ?string ;
1044
+ astNode ?: ?ASTNode ;
1020
1045
isIntrospection ?: boolean ;
1021
1046
} ;
1022
1047
@@ -1028,13 +1053,15 @@ export type GraphQLEnumValueConfig/* <T> */ = {
1028
1053
value ?: any /* T */ ;
1029
1054
deprecationReason ?: ?string ;
1030
1055
description ?: ?string ;
1056
+ astNode ?: ?ASTNode ;
1031
1057
} ;
1032
1058
1033
1059
export type GraphQLEnumValue /* <T> */ = {
1034
1060
name : string ;
1035
1061
description : ?string ;
1036
1062
isDeprecated ?: boolean ;
1037
1063
deprecationReason : ?string ;
1064
+ astNode ?: ?ASTNode ;
1038
1065
value : any /* T */ ;
1039
1066
} ;
1040
1067
@@ -1063,6 +1090,7 @@ export type GraphQLEnumValue/* <T> */ = {
1063
1090
export class GraphQLInputObjectType {
1064
1091
name : string ;
1065
1092
description : ?string ;
1093
+ astNode : ?ASTNode ;
1066
1094
1067
1095
_typeConfig : GraphQLInputObjectTypeConfig ;
1068
1096
_fields : GraphQLInputFieldMap ;
@@ -1071,6 +1099,7 @@ export class GraphQLInputObjectType {
1071
1099
assertValidName ( config . name ) ;
1072
1100
this . name = config . name ;
1073
1101
this . description = config . description ;
1102
+ this . astNode = config . astNode || null ;
1074
1103
this . _typeConfig = config ;
1075
1104
}
1076
1105
@@ -1130,12 +1159,14 @@ export type GraphQLInputObjectTypeConfig = {
1130
1159
name : string ;
1131
1160
fields : Thunk < GraphQLInputFieldConfigMap > ;
1132
1161
description ?: ?string ;
1162
+ astNode ?: ?ASTNode ;
1133
1163
} ;
1134
1164
1135
1165
export type GraphQLInputFieldConfig = {
1136
1166
type : GraphQLInputType ;
1137
1167
defaultValue ?: mixed ;
1138
1168
description ?: ?string ;
1169
+ astNode ?: ?ASTNode ;
1139
1170
} ;
1140
1171
1141
1172
export type GraphQLInputFieldConfigMap = {
@@ -1147,6 +1178,7 @@ export type GraphQLInputField = {
1147
1178
type : GraphQLInputType ;
1148
1179
defaultValue ?: mixed ;
1149
1180
description ?: ?string ;
1181
+ astNode ?: ?ASTNode ;
1150
1182
} ;
1151
1183
1152
1184
export type GraphQLInputFieldMap = {
0 commit comments