@@ -35,6 +35,7 @@ import type {
35
35
OperationDefinitionNode ,
36
36
FieldNode ,
37
37
FragmentDefinitionNode ,
38
+ DirectiveNode ,
38
39
ValueNode ,
39
40
} from '../language/ast' ;
40
41
import type { GraphQLSchema } from './schema' ;
@@ -541,6 +542,8 @@ export class GraphQLScalarType {
541
542
astNode : ?ScalarTypeDefinitionNode ;
542
543
extensionASTNodes : ?$ReadOnlyArray < ScalarTypeExtensionNode > ;
543
544
545
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
546
+
544
547
constructor ( config : GraphQLScalarTypeConfig < * , * > ) : void {
545
548
this . name = config . name ;
546
549
this . description = config . description ;
@@ -566,6 +569,28 @@ export class GraphQLScalarType {
566
569
}
567
570
}
568
571
572
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
573
+ if ( this . _directives ) {
574
+ return this . _directives ;
575
+ }
576
+
577
+ const directives = [ ] ;
578
+ if ( this . astNode && this . astNode . directives ) {
579
+ directives . push ( ...this . astNode . directives ) ;
580
+ }
581
+ const extensionASTNodes = this . extensionASTNodes ;
582
+ if ( extensionASTNodes ) {
583
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
584
+ const extensionNode = extensionASTNodes [ i ] ;
585
+ if ( extensionNode . directives ) {
586
+ directives . push ( ...extensionNode . directives ) ;
587
+ }
588
+ }
589
+ }
590
+ this . _directives = directives ;
591
+ return directives ;
592
+ }
593
+
569
594
toString ( ) : string {
570
595
return this . name ;
571
596
}
@@ -641,6 +666,7 @@ export class GraphQLObjectType {
641
666
642
667
_fields : Thunk < GraphQLFieldMap < * , * > > ;
643
668
_interfaces : Thunk < Array < GraphQLInterfaceType > > ;
669
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
644
670
645
671
constructor ( config : GraphQLObjectTypeConfig < * , * > ) : void {
646
672
this . name = config . name ;
@@ -659,6 +685,28 @@ export class GraphQLObjectType {
659
685
}
660
686
}
661
687
688
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
689
+ if ( this . _directives ) {
690
+ return this . _directives ;
691
+ }
692
+
693
+ const directives = [ ] ;
694
+ if ( this . astNode && this . astNode . directives ) {
695
+ directives . push ( ...this . astNode . directives ) ;
696
+ }
697
+ const extensionASTNodes = this . extensionASTNodes ;
698
+ if ( extensionASTNodes ) {
699
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
700
+ const extensionNode = extensionASTNodes [ i ] ;
701
+ if ( extensionNode . directives ) {
702
+ directives . push ( ...extensionNode . directives ) ;
703
+ }
704
+ }
705
+ }
706
+ this . _directives = directives ;
707
+ return directives ;
708
+ }
709
+
662
710
getFields ( ) : GraphQLFieldMap < * , * > {
663
711
if ( typeof this . _fields === 'function' ) {
664
712
this . _fields = this . _fields ( ) ;
@@ -894,6 +942,7 @@ export class GraphQLInterfaceType {
894
942
resolveType : ?GraphQLTypeResolver < * , * > ;
895
943
896
944
_fields : Thunk < GraphQLFieldMap < * , * > > ;
945
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
897
946
898
947
constructor ( config : GraphQLInterfaceTypeConfig < * , * > ) : void {
899
948
this . name = config . name ;
@@ -911,6 +960,28 @@ export class GraphQLInterfaceType {
911
960
}
912
961
}
913
962
963
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
964
+ if ( this . _directives ) {
965
+ return this . _directives ;
966
+ }
967
+
968
+ const directives = [ ] ;
969
+ if ( this . astNode && this . astNode . directives ) {
970
+ directives . push ( ...this . astNode . directives ) ;
971
+ }
972
+ const extensionASTNodes = this . extensionASTNodes ;
973
+ if ( extensionASTNodes ) {
974
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
975
+ const extensionNode = extensionASTNodes [ i ] ;
976
+ if ( extensionNode . directives ) {
977
+ directives . push ( ...extensionNode . directives ) ;
978
+ }
979
+ }
980
+ }
981
+ this . _directives = directives ;
982
+ return directives ;
983
+ }
984
+
914
985
getFields ( ) : GraphQLFieldMap < * , * > {
915
986
if ( typeof this . _fields === 'function' ) {
916
987
this . _fields = this . _fields ( ) ;
@@ -972,6 +1043,7 @@ export class GraphQLUnionType {
972
1043
resolveType : ?GraphQLTypeResolver < * , * > ;
973
1044
974
1045
_types : Thunk < Array < GraphQLObjectType > > ;
1046
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
975
1047
976
1048
constructor ( config : GraphQLUnionTypeConfig < * , * > ) : void {
977
1049
this . name = config . name ;
@@ -989,6 +1061,28 @@ export class GraphQLUnionType {
989
1061
}
990
1062
}
991
1063
1064
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
1065
+ if ( this . _directives ) {
1066
+ return this . _directives ;
1067
+ }
1068
+
1069
+ const directives = [ ] ;
1070
+ if ( this . astNode && this . astNode . directives ) {
1071
+ directives . push ( ...this . astNode . directives ) ;
1072
+ }
1073
+ const extensionASTNodes = this . extensionASTNodes ;
1074
+ if ( extensionASTNodes ) {
1075
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
1076
+ const extensionNode = extensionASTNodes [ i ] ;
1077
+ if ( extensionNode . directives ) {
1078
+ directives . push ( ...extensionNode . directives ) ;
1079
+ }
1080
+ }
1081
+ }
1082
+ this . _directives = directives ;
1083
+ return directives ;
1084
+ }
1085
+
992
1086
getTypes ( ) : Array < GraphQLObjectType > {
993
1087
if ( typeof this . _types === 'function' ) {
994
1088
this . _types = this . _types ( ) ;
@@ -1058,6 +1152,7 @@ export class GraphQLEnumType /* <T> */ {
1058
1152
astNode : ?EnumTypeDefinitionNode ;
1059
1153
extensionASTNodes : ?$ReadOnlyArray < EnumTypeExtensionNode > ;
1060
1154
1155
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
1061
1156
_values : Array < GraphQLEnumValue /* <T> */ > ;
1062
1157
_valueLookup : Map < any /* T */ , GraphQLEnumValue > ;
1063
1158
_nameLookup : ObjMap < GraphQLEnumValue > ;
@@ -1076,6 +1171,28 @@ export class GraphQLEnumType /* <T> */ {
1076
1171
invariant ( typeof config . name === 'string' , 'Must provide name.' ) ;
1077
1172
}
1078
1173
1174
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
1175
+ if ( this . _directives ) {
1176
+ return this . _directives ;
1177
+ }
1178
+
1179
+ const directives = [ ] ;
1180
+ if ( this . astNode && this . astNode . directives ) {
1181
+ directives . push ( ...this . astNode . directives ) ;
1182
+ }
1183
+ const extensionASTNodes = this . extensionASTNodes ;
1184
+ if ( extensionASTNodes ) {
1185
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
1186
+ const extensionNode = extensionASTNodes [ i ] ;
1187
+ if ( extensionNode . directives ) {
1188
+ directives . push ( ...extensionNode . directives ) ;
1189
+ }
1190
+ }
1191
+ }
1192
+ this . _directives = directives ;
1193
+ return directives ;
1194
+ }
1195
+
1079
1196
getValues ( ) : Array < GraphQLEnumValue /* <T> */ > {
1080
1197
return this . _values ;
1081
1198
}
@@ -1204,6 +1321,7 @@ export class GraphQLInputObjectType {
1204
1321
astNode : ?InputObjectTypeDefinitionNode ;
1205
1322
extensionASTNodes : ?$ReadOnlyArray < InputObjectTypeExtensionNode > ;
1206
1323
1324
+ _directives : ?$ReadOnlyArray < DirectiveNode > ;
1207
1325
_fields : Thunk < GraphQLInputFieldMap > ;
1208
1326
1209
1327
constructor ( config : GraphQLInputObjectTypeConfig ) : void {
@@ -1215,6 +1333,28 @@ export class GraphQLInputObjectType {
1215
1333
invariant ( typeof config . name === 'string' , 'Must provide name.' ) ;
1216
1334
}
1217
1335
1336
+ getDirectives ( ) : $ReadOnlyArray < DirectiveNode > {
1337
+ if ( this . _directives ) {
1338
+ return this . _directives ;
1339
+ }
1340
+
1341
+ const directives = [ ] ;
1342
+ if ( this . astNode && this . astNode . directives ) {
1343
+ directives . push ( ...this . astNode . directives ) ;
1344
+ }
1345
+ const extensionASTNodes = this . extensionASTNodes ;
1346
+ if ( extensionASTNodes ) {
1347
+ for ( let i = 0 ; i < extensionASTNodes . length ; i ++ ) {
1348
+ const extensionNode = extensionASTNodes [ i ] ;
1349
+ if ( extensionNode . directives ) {
1350
+ directives . push ( ...extensionNode . directives ) ;
1351
+ }
1352
+ }
1353
+ }
1354
+ this . _directives = directives ;
1355
+ return directives ;
1356
+ }
1357
+
1218
1358
getFields ( ) : GraphQLInputFieldMap {
1219
1359
if ( typeof this . _fields === 'function' ) {
1220
1360
this . _fields = this . _fields ( ) ;
0 commit comments