@@ -13,6 +13,16 @@ import isNullish from '../jsutils/isNullish';
13
13
import { ENUM } from '../language/kinds' ;
14
14
import { assertValidName } from '../utilities/assertValidName' ;
15
15
import type {
16
+ ScalarTypeDefinitionNode ,
17
+ ObjectTypeDefinitionNode ,
18
+ FieldDefinitionNode ,
19
+ InputValueDefinitionNode ,
20
+ InterfaceTypeDefinitionNode ,
21
+ UnionTypeDefinitionNode ,
22
+ EnumTypeDefinitionNode ,
23
+ EnumValueDefinitionNode ,
24
+ InputObjectTypeDefinitionNode ,
25
+ TypeExtensionDefinitionNode ,
16
26
OperationDefinitionNode ,
17
27
FieldNode ,
18
28
FragmentDefinitionNode ,
@@ -294,13 +304,15 @@ function resolveThunk<T>(thunk: Thunk<T>): T {
294
304
export class GraphQLScalarType {
295
305
name : string ;
296
306
description : ?string ;
307
+ astNode : ?ScalarTypeDefinitionNode ;
297
308
298
309
_scalarConfig : GraphQLScalarTypeConfig < * , * > ;
299
310
300
311
constructor ( config : GraphQLScalarTypeConfig < * , * > ) : void {
301
312
assertValidName ( config . name ) ;
302
313
this . name = config . name ;
303
314
this . description = config . description ;
315
+ this . astNode = config . astNode || null ;
304
316
invariant (
305
317
typeof config . serialize === 'function' ,
306
318
`${ this . name } must provide "serialize" function. If this custom Scalar ` +
@@ -364,6 +376,7 @@ GraphQLScalarType.prototype.toJSON =
364
376
export type GraphQLScalarTypeConfig < TInternal , TExternal > = {
365
377
name : string ;
366
378
description ?: ?string ;
379
+ astNode ?: ?ScalarTypeDefinitionNode ;
367
380
serialize : ( value : mixed ) => ?TExternal ;
368
381
parseValue ?: ( value : mixed ) => ?TInternal ;
369
382
parseLiteral ?: ( valueNode : ValueNode ) => ?TInternal ;
@@ -411,6 +424,8 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {
411
424
export class GraphQLObjectType {
412
425
name : string ;
413
426
description : ?string ;
427
+ astNode : ?ObjectTypeDefinitionNode ;
428
+ extensionASTNodes : Array < TypeExtensionDefinitionNode > ;
414
429
isTypeOf : ?GraphQLIsTypeOfFn < * , * > ;
415
430
416
431
_typeConfig : GraphQLObjectTypeConfig < * , * > ;
@@ -421,6 +436,8 @@ export class GraphQLObjectType {
421
436
assertValidName ( config . name , config . isIntrospection ) ;
422
437
this . name = config . name ;
423
438
this . description = config . description ;
439
+ this . astNode = config . astNode || null ;
440
+ this . extensionASTNodes = config . extensionASTNodes || [ ] ;
424
441
if ( config . isTypeOf ) {
425
442
invariant (
426
443
typeof config . isTypeOf === 'function' ,
@@ -562,7 +579,8 @@ function defineFieldMap<TSource, TContext>(
562
579
name : argName ,
563
580
description : arg . description === undefined ? null : arg . description ,
564
581
type : arg . type ,
565
- defaultValue : arg . defaultValue
582
+ defaultValue : arg . defaultValue ,
583
+ astNode : arg . astNode ,
566
584
} ;
567
585
} ) ;
568
586
}
@@ -587,6 +605,8 @@ export type GraphQLObjectTypeConfig<TSource, TContext> = {
587
605
isTypeOf ?: ?GraphQLIsTypeOfFn < TSource , TContext > ;
588
606
description ?: ?string ;
589
607
isIntrospection ?: boolean ;
608
+ astNode ?: ?ObjectTypeDefinitionNode ;
609
+ extensionASTNodes ?: ?Array < TypeExtensionDefinitionNode > ;
590
610
} ;
591
611
592
612
export type GraphQLTypeResolver < TSource , TContext > = (
@@ -630,6 +650,7 @@ export type GraphQLFieldConfig<TSource, TContext> = {
630
650
subscribe ?: GraphQLFieldResolver < TSource , TContext > ;
631
651
deprecationReason ?: ?string ;
632
652
description ?: ?string ;
653
+ astNode ?: ?FieldDefinitionNode ;
633
654
} ;
634
655
635
656
export type GraphQLFieldConfigArgumentMap = {
@@ -640,6 +661,7 @@ export type GraphQLArgumentConfig = {
640
661
type : GraphQLInputType ;
641
662
defaultValue ?: mixed ;
642
663
description ?: ?string ;
664
+ astNode ?: ?InputValueDefinitionNode ;
643
665
} ;
644
666
645
667
export type GraphQLFieldConfigMap < TSource , TContext > = {
@@ -655,13 +677,15 @@ export type GraphQLField<TSource, TContext> = {
655
677
subscribe ?: GraphQLFieldResolver < TSource , TContext > ;
656
678
isDeprecated ?: boolean ;
657
679
deprecationReason ?: ?string ;
680
+ astNode ?: ?FieldDefinitionNode ;
658
681
} ;
659
682
660
683
export type GraphQLArgument = {
661
684
name : string ;
662
685
type : GraphQLInputType ;
663
686
defaultValue ?: mixed ;
664
687
description ?: ?string ;
688
+ astNode ?: ?InputValueDefinitionNode ;
665
689
} ;
666
690
667
691
export type GraphQLFieldMap < TSource , TContext > = {
@@ -691,6 +715,7 @@ export type GraphQLFieldMap<TSource, TContext> = {
691
715
export class GraphQLInterfaceType {
692
716
name : string ;
693
717
description : ?string ;
718
+ astNode : ?InterfaceTypeDefinitionNode ;
694
719
resolveType : ?GraphQLTypeResolver < * , * > ;
695
720
696
721
_typeConfig : GraphQLInterfaceTypeConfig < * , * > ;
@@ -700,6 +725,7 @@ export class GraphQLInterfaceType {
700
725
assertValidName ( config . name ) ;
701
726
this . name = config . name ;
702
727
this . description = config . description ;
728
+ this . astNode = config . astNode || null ;
703
729
if ( config . resolveType ) {
704
730
invariant (
705
731
typeof config . resolveType === 'function' ,
@@ -737,7 +763,8 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
737
763
* Object type.
738
764
*/
739
765
resolveType ?: ?GraphQLTypeResolver < TSource , TContext> ,
740
- description ?: ?string
766
+ description ?: ?string ,
767
+ astNode ?: ?InterfaceTypeDefinitionNode ,
741
768
} ;
742
769
743
770
@@ -768,6 +795,7 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
768
795
export class GraphQLUnionType {
769
796
name : string ;
770
797
description : ?string ;
798
+ astNode : ?UnionTypeDefinitionNode ;
771
799
resolveType : ?GraphQLTypeResolver < * , * > ;
772
800
773
801
_typeConfig : GraphQLUnionTypeConfig < * , * > ;
@@ -778,6 +806,7 @@ export class GraphQLUnionType {
778
806
assertValidName ( config . name ) ;
779
807
this . name = config . name ;
780
808
this . description = config . description ;
809
+ this . astNode = config . astNode || null ;
781
810
if ( config . resolveType ) {
782
811
invariant (
783
812
typeof config . resolveType === 'function' ,
@@ -854,6 +883,7 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {
854
883
*/
855
884
resolveType ?: ?GraphQLTypeResolver < TSource , TContext > ;
856
885
description ?: ?string ;
886
+ astNode ?: ?UnionTypeDefinitionNode ;
857
887
} ;
858
888
859
889
@@ -882,6 +912,7 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {
882
912
export class GraphQLEnumType /* <T> */ {
883
913
name : string ;
884
914
description : ?string ;
915
+ astNode : ?EnumTypeDefinitionNode ;
885
916
886
917
_enumConfig : GraphQLEnumTypeConfig /* <T> */ ;
887
918
_values : Array < GraphQLEnumValue /* <T> */ > ;
@@ -892,6 +923,7 @@ export class GraphQLEnumType/* <T> */ {
892
923
this. name = config . name ;
893
924
assertValidName ( config . name , config . isIntrospection ) ;
894
925
this . description = config . description ;
926
+ this . astNode = config . astNode || null ;
895
927
this . _values = defineEnumValues ( this , config . values ) ;
896
928
this . _enumConfig = config ;
897
929
}
@@ -1008,6 +1040,7 @@ function defineEnumValues(
1008
1040
description : value . description ,
1009
1041
isDeprecated : Boolean ( value . deprecationReason ) ,
1010
1042
deprecationReason : value . deprecationReason ,
1043
+ astNode : value . astNode || null ,
1011
1044
value : value . hasOwnProperty ( 'value' ) ? value . value : valueName ,
1012
1045
} ;
1013
1046
} ) ;
@@ -1017,6 +1050,7 @@ export type GraphQLEnumTypeConfig/* <T> */ = {
1017
1050
name : string ;
1018
1051
values : GraphQLEnumValueConfigMap /* <T> */ ;
1019
1052
description ?: ?string ;
1053
+ astNode ?: ?EnumTypeDefinitionNode ;
1020
1054
isIntrospection ?: boolean ;
1021
1055
} ;
1022
1056
@@ -1028,13 +1062,15 @@ export type GraphQLEnumValueConfig/* <T> */ = {
1028
1062
value ?: any /* T */ ;
1029
1063
deprecationReason ?: ?string ;
1030
1064
description ?: ?string ;
1065
+ astNode ?: ?EnumValueDefinitionNode ;
1031
1066
} ;
1032
1067
1033
1068
export type GraphQLEnumValue /* <T> */ = {
1034
1069
name : string ;
1035
1070
description : ?string ;
1036
1071
isDeprecated ?: boolean ;
1037
1072
deprecationReason : ?string ;
1073
+ astNode ?: ?EnumValueDefinitionNode ;
1038
1074
value : any /* T */ ;
1039
1075
} ;
1040
1076
@@ -1063,6 +1099,7 @@ export type GraphQLEnumValue/* <T> */ = {
1063
1099
export class GraphQLInputObjectType {
1064
1100
name : string ;
1065
1101
description : ?string ;
1102
+ astNode : ?InputObjectTypeDefinitionNode ;
1066
1103
1067
1104
_typeConfig : GraphQLInputObjectTypeConfig ;
1068
1105
_fields : GraphQLInputFieldMap ;
@@ -1071,6 +1108,7 @@ export class GraphQLInputObjectType {
1071
1108
assertValidName ( config . name ) ;
1072
1109
this . name = config . name ;
1073
1110
this . description = config . description ;
1111
+ this . astNode = config . astNode || null ;
1074
1112
this . _typeConfig = config ;
1075
1113
}
1076
1114
@@ -1130,12 +1168,14 @@ export type GraphQLInputObjectTypeConfig = {
1130
1168
name : string ;
1131
1169
fields : Thunk < GraphQLInputFieldConfigMap > ;
1132
1170
description ?: ?string ;
1171
+ astNode ?: ?InputObjectTypeDefinitionNode ;
1133
1172
} ;
1134
1173
1135
1174
export type GraphQLInputFieldConfig = {
1136
1175
type : GraphQLInputType ;
1137
1176
defaultValue ?: mixed ;
1138
1177
description ?: ?string ;
1178
+ astNode ?: ?InputValueDefinitionNode ;
1139
1179
} ;
1140
1180
1141
1181
export type GraphQLInputFieldConfigMap = {
@@ -1147,6 +1187,7 @@ export type GraphQLInputField = {
1147
1187
type : GraphQLInputType ;
1148
1188
defaultValue ?: mixed ;
1149
1189
description ?: ?string ;
1190
+ astNode ?: ?InputValueDefinitionNode ;
1150
1191
} ;
1151
1192
1152
1193
export type GraphQLInputFieldMap = {
0 commit comments