1
- export type GraphQLGrammarType = {
2
- [ string ] : GraphQLGrammarRule ,
3
- } ;
1
+ export type GraphQLGrammarType = { |
2
+ [ name : string ] : GraphQLGrammarRule ,
3
+ | } ;
4
4
export type GraphQLGrammarRuleName = string ;
5
5
export type GraphQLGrammarRuleConstraint =
6
6
| GraphQLGrammarTokenConstraint
7
7
| GraphQLGrammarOfTypeConstraint
8
8
| GraphQLGrammarListOfTypeConstraint
9
9
| GraphQLGrammarPeekConstraint ;
10
- export type GraphQLGrammarConstraintsSet = Array < GraphQLGrammarRuleName | GraphQLGrammarRuleConstraint > ;
11
- export type GraphQLGrammarRule = GraphQLGrammarRuleName | GraphQLGrammarRuleConstraint | GraphQLGrammarConstraintsSet ;
10
+ export type GraphQLGrammarConstraintsSet = Array <
11
+ GraphQLGrammarRuleName | GraphQLGrammarRuleConstraint ,
12
+ > ;
13
+ export type GraphQLGrammarRule =
14
+ | GraphQLGrammarRuleName
15
+ | GraphQLGrammarRuleConstraint
16
+ | GraphQLGrammarConstraintsSet ;
12
17
export interface GraphQLGrammarBaseRuleConstraint {
13
- butNot ?: ?GraphQLGrammarTokenConstraint | ?Array < GraphQLGrammarTokenConstraint > ;
18
+ butNot ?:
19
+ | ?GraphQLGrammarTokenConstraint
20
+ | ?Array < GraphQLGrammarTokenConstraint > ;
14
21
optional ? : boolean ;
15
22
eatNextOnFail ? : boolean ;
16
23
}
17
- export interface GraphQLGrammarTokenConstraint extends GraphQLGrammarBaseRuleConstraint {
24
+ export interface GraphQLGrammarTokenConstraint
25
+ extends GraphQLGrammarBaseRuleConstraint {
18
26
token :
19
27
| '!'
20
28
| '$'
@@ -42,14 +50,17 @@ export interface GraphQLGrammarTokenConstraint extends GraphQLGrammarBaseRuleCon
42
50
definitionName ? : boolean ;
43
51
typeName ? : boolean ;
44
52
}
45
- export interface GraphQLGrammarOfTypeConstraint extends GraphQLGrammarBaseRuleConstraint {
53
+ export interface GraphQLGrammarOfTypeConstraint
54
+ extends GraphQLGrammarBaseRuleConstraint {
46
55
ofType: GraphQLGrammarRule ;
47
56
tokenName ? : string ;
48
57
}
49
- export interface GraphQLGrammarListOfTypeConstraint extends GraphQLGrammarBaseRuleConstraint {
58
+ export interface GraphQLGrammarListOfTypeConstraint
59
+ extends GraphQLGrammarBaseRuleConstraint {
50
60
listOfType: GraphQLGrammarRuleName ;
51
61
}
52
- export interface GraphQLGrammarPeekConstraint extends GraphQLGrammarBaseRuleConstraint {
62
+ export interface GraphQLGrammarPeekConstraint
63
+ extends GraphQLGrammarBaseRuleConstraint {
53
64
peek: Array < GraphQLGrammarPeekConstraintCondition > ;
54
65
}
55
66
export interface GraphQLGrammarPeekConstraintCondition {
@@ -58,10 +69,10 @@ export interface GraphQLGrammarPeekConstraintCondition {
58
69
end ? : boolean ;
59
70
}
60
71
61
- const grammar : GraphQLGrammarType = {
62
- Name : ( { token : 'Name' } : GraphQLGrammarTokenConstraint ) ,
63
- String : ( { token : 'String' } : GraphQLGrammarTokenConstraint ) ,
64
- BlockString : ( { token : 'BlockString' } : GraphQLGrammarTokenConstraint ) ,
72
+ const grammar : GraphQLGrammarType = ( {
73
+ Name : { token : 'Name' } ,
74
+ String : { token : 'String' } ,
75
+ BlockString : { token : 'BlockString' } ,
65
76
66
77
Document : { listOfType : 'Definition' } ,
67
78
Definition : {
@@ -80,7 +91,16 @@ const grammar: GraphQLGrammarType = {
80
91
{
81
92
ifCondition : {
82
93
token : 'Name' ,
83
- oneOf : [ 'schema' , 'scalar' , 'type' , 'interface' , 'union' , 'enum' , 'input' , 'directive' ] ,
94
+ oneOf : [
95
+ 'schema' ,
96
+ 'scalar' ,
97
+ 'type' ,
98
+ 'interface' ,
99
+ 'union' ,
100
+ 'enum' ,
101
+ 'input' ,
102
+ 'directive' ,
103
+ ] ,
84
104
} ,
85
105
expect : 'TypeSystemDefinition' ,
86
106
} ,
@@ -103,7 +123,7 @@ const grammar: GraphQLGrammarType = {
103
123
] ,
104
124
} ,
105
125
106
- OperationDefinition : ( {
126
+ OperationDefinition : {
107
127
peek : [
108
128
{
109
129
ifCondition : { token : '{' } ,
@@ -128,7 +148,7 @@ const grammar: GraphQLGrammarType = {
128
148
] ,
129
149
} ,
130
150
] ,
131
- } : GraphQLGrammarPeekConstraint ) ,
151
+ } ,
132
152
OperationType : {
133
153
ofType : 'OperationTypeName' ,
134
154
} ,
@@ -165,9 +185,16 @@ const grammar: GraphQLGrammarType = {
165
185
] ,
166
186
167
187
Arguments : [ { token : '(' } , { listOfType : 'Argument' } , { token : ')' } ] ,
168
- Argument : [ { token : 'Name' , tokenName : 'ArgumentName' , definitionName : true } , { token : ':' } , 'Value' ] ,
188
+ Argument : [
189
+ { token : 'Name' , tokenName : 'ArgumentName' , definitionName : true } ,
190
+ { token : ':' } ,
191
+ 'Value' ,
192
+ ] ,
169
193
170
- Alias : [ { token : 'Name' , tokenName : 'AliasName' , definitionName : true } , { token : ':' } ] ,
194
+ Alias : [
195
+ { token : 'Name' , tokenName : 'AliasName' , definitionName : true } ,
196
+ { token : ':' } ,
197
+ ] ,
171
198
172
199
Fragment : [
173
200
{ token : '...' } ,
@@ -211,7 +238,10 @@ const grammar: GraphQLGrammarType = {
211
238
definitionName : true ,
212
239
} ,
213
240
214
- TypeCondition : [ { token : 'Name' , ofValue : 'on' , tokenName : 'OnKeyword' } , 'TypeName' ] ,
241
+ TypeCondition : [
242
+ { token : 'Name' , ofValue : 'on' , tokenName : 'OnKeyword' } ,
243
+ 'TypeName' ,
244
+ ] ,
215
245
216
246
InlineFragment : [
217
247
{ ofType : 'TypeCondition' , optional : true } ,
@@ -340,19 +370,44 @@ const grammar: GraphQLGrammarType = {
340
370
tokenName : 'EnumValue' ,
341
371
} ,
342
372
343
- ListValue : [ { token : '[' } , { listOfType : 'Value' , optional : true } , { token : ']' } ] ,
373
+ ListValue : [
374
+ { token : '[' } ,
375
+ { listOfType : 'Value' , optional : true } ,
376
+ { token : ']' } ,
377
+ ] ,
344
378
345
- ConstListValue : [ { token : '[' } , { listOfType : 'ConstValue' , optional : true } , { token : ']' } ] ,
379
+ ConstListValue : [
380
+ { token : '[' } ,
381
+ { listOfType : 'ConstValue' , optional : true } ,
382
+ { token : ']' } ,
383
+ ] ,
346
384
347
- ObjectValue : [ { token : '{' } , { listOfType : 'ObjectField' , optional : true } , { token : '}' } ] ,
348
- ObjectField : [ { token : 'Name' , tokenName : 'ObjectFieldName' } , { token : ':' } , { ofType : 'ConstValue' } ] ,
385
+ ObjectValue : [
386
+ { token : '{' } ,
387
+ { listOfType : 'ObjectField' , optional : true } ,
388
+ { token : '}' } ,
389
+ ] ,
390
+ ObjectField : [
391
+ { token : 'Name' , tokenName : 'ObjectFieldName' } ,
392
+ { token : ':' } ,
393
+ { ofType : 'ConstValue' } ,
394
+ ] ,
349
395
350
396
Variable : [
351
397
{ token : '$' , tokenName : 'VariableName' } ,
352
398
{ token : 'Name' , tokenName : 'VariableName' } ,
353
399
] ,
354
- VariableDefinitions : [ { token : '(' } , { listOfType : 'VariableDefinition' } , { token : ')' } ] ,
355
- VariableDefinition : [ 'Variable' , { token : ':' } , 'Type' , { ofType : 'DefaultValue' , optional : true } ] ,
400
+ VariableDefinitions : [
401
+ { token : '(' } ,
402
+ { listOfType : 'VariableDefinition' } ,
403
+ { token : ')' } ,
404
+ ] ,
405
+ VariableDefinition : [
406
+ 'Variable' ,
407
+ { token : ':' } ,
408
+ 'Type' ,
409
+ { ofType : 'DefaultValue' , optional : true } ,
410
+ ] ,
356
411
DefaultValue : [ { token : '=' } , 'ConstValue' ] ,
357
412
358
413
TypeName : { token : 'Name' , tokenName : 'TypeName' , typeName : true } ,
@@ -369,7 +424,12 @@ const grammar: GraphQLGrammarType = {
369
424
} ,
370
425
] ,
371
426
} ,
372
- ListType : [ { token : '[' } , { listOfType : 'Type' } , { token : ']' } , { token : '!' , optional : true } ] ,
427
+ ListType : [
428
+ { token : '[' } ,
429
+ { listOfType : 'Type' } ,
430
+ { token : ']' } ,
431
+ { token : '!' , optional : true } ,
432
+ ] ,
373
433
374
434
Directives : { listOfType : 'Directive' } ,
375
435
Directive : [
@@ -524,14 +584,22 @@ const grammar: GraphQLGrammarType = {
524
584
expect : [
525
585
'Directives' ,
526
586
{
527
- ofType : [ { token : '{' } , { listOfType : 'RootOperationTypeDefinition' } , { token : '}' } ] ,
587
+ ofType : [
588
+ { token : '{' } ,
589
+ { listOfType : 'RootOperationTypeDefinition' } ,
590
+ { token : '}' } ,
591
+ ] ,
528
592
optional : true ,
529
593
} ,
530
594
] ,
531
595
} ,
532
596
{
533
597
ifCondition : { token : '{' } ,
534
- expect : [ { token : '{' } , { listOfType : 'RootOperationTypeDefinition' } , { token : '}' } ] ,
598
+ expect : [
599
+ { token : '{' } ,
600
+ { listOfType : 'RootOperationTypeDefinition' } ,
601
+ { token : '}' } ,
602
+ ] ,
535
603
} ,
536
604
] ,
537
605
} ,
@@ -591,7 +659,11 @@ const grammar: GraphQLGrammarType = {
591
659
} ,
592
660
] ,
593
661
ImplementsAdditionalInterfaceName : [ { token : '&' } , 'TypeName' ] ,
594
- FieldsDefinition : [ { token : '{' } , { listOfType : 'FieldDefinition' } , { token : '}' } ] ,
662
+ FieldsDefinition : [
663
+ { token : '{' } ,
664
+ { listOfType : 'FieldDefinition' } ,
665
+ { token : '}' } ,
666
+ ] ,
595
667
FieldDefinition : [
596
668
{ ofType : 'Description' , optional : true } ,
597
669
{ token : 'Name' , tokenName : 'AliasName' , definitionName : true } ,
@@ -601,7 +673,11 @@ const grammar: GraphQLGrammarType = {
601
673
{ ofType : 'Directives' , optional : true } ,
602
674
] ,
603
675
604
- ArgumentsDefinition : [ { token : '(' } , { listOfType : 'InputValueDefinition' } , { token : ')' } ] ,
676
+ ArgumentsDefinition : [
677
+ { token : '(' } ,
678
+ { listOfType : 'InputValueDefinition' } ,
679
+ { token : ')' } ,
680
+ ] ,
605
681
InputValueDefinition : [
606
682
{ ofType : 'Description' , optional : true } ,
607
683
{ token : 'Name' , tokenName : 'ArgumentName' } ,
@@ -633,7 +709,10 @@ const grammar: GraphQLGrammarType = {
633
709
peek : [
634
710
{
635
711
ifCondition : { token : '@' } ,
636
- expect : [ 'Directives' , { ofType : 'FieldsDefinition' , optional : true } ] ,
712
+ expect : [
713
+ 'Directives' ,
714
+ { ofType : 'FieldsDefinition' , optional : true } ,
715
+ ] ,
637
716
} ,
638
717
{
639
718
ifCondition : { token : '{' } ,
@@ -646,7 +725,10 @@ const grammar: GraphQLGrammarType = {
646
725
} ,
647
726
{
648
727
ifCondition : { token : '@' } ,
649
- expect : [ 'Directives' , { ofType : 'FieldsDefinition' , optional : true } ] ,
728
+ expect : [
729
+ 'Directives' ,
730
+ { ofType : 'FieldsDefinition' , optional : true } ,
731
+ ] ,
650
732
} ,
651
733
{
652
734
ifCondition : { token : '{' } ,
@@ -684,7 +766,10 @@ const grammar: GraphQLGrammarType = {
684
766
peek : [
685
767
{
686
768
ifCondition : { token : '@' } ,
687
- expect : [ 'Directives' , { ofType : 'FieldsDefinition' , optional : true } ] ,
769
+ expect : [
770
+ 'Directives' ,
771
+ { ofType : 'FieldsDefinition' , optional : true } ,
772
+ ] ,
688
773
} ,
689
774
{
690
775
ifCondition : { token : '{' } ,
@@ -734,7 +819,10 @@ const grammar: GraphQLGrammarType = {
734
819
peek : [
735
820
{
736
821
ifCondition : { token : '@' } ,
737
- expect : [ 'Directives' , { ofType : 'UnionMemberTypes' , optional : true } ] ,
822
+ expect : [
823
+ 'Directives' ,
824
+ { ofType : 'UnionMemberTypes' , optional : true } ,
825
+ ] ,
738
826
} ,
739
827
{
740
828
ifCondition : { token : '=' } ,
@@ -755,7 +843,11 @@ const grammar: GraphQLGrammarType = {
755
843
{ ofType : 'Directives' , optional : true } ,
756
844
{ ofType : 'EnumValuesDefinition' , optional : true } ,
757
845
] ,
758
- EnumValuesDefinition : [ { token : '{' } , { listOfType : 'EnumValueDefinition' } , { token : '}' } ] ,
846
+ EnumValuesDefinition : [
847
+ { token : '{' } ,
848
+ { listOfType : 'EnumValueDefinition' } ,
849
+ { token : '}' } ,
850
+ ] ,
759
851
EnumValueDefinition : [
760
852
{ ofType : 'Description' , optional : true } ,
761
853
'EnumValue' ,
@@ -778,7 +870,10 @@ const grammar: GraphQLGrammarType = {
778
870
peek : [
779
871
{
780
872
ifCondition : { token : '@' } ,
781
- expect : [ 'Directives' , { ofType : 'EnumValuesDefinition' , optional : true } ] ,
873
+ expect : [
874
+ 'Directives' ,
875
+ { ofType : 'EnumValuesDefinition' , optional : true } ,
876
+ ] ,
782
877
} ,
783
878
{
784
879
ifCondition : { token : '{' } ,
@@ -799,7 +894,11 @@ const grammar: GraphQLGrammarType = {
799
894
{ ofType : 'Directives' , optional : true } ,
800
895
{ ofType : 'InputFieldsDefinition' , optional : true } ,
801
896
] ,
802
- InputFieldsDefinition : [ { token : '{' } , { listOfType : 'InputValueDefinition' } , { token : '}' } ] ,
897
+ InputFieldsDefinition : [
898
+ { token : '{' } ,
899
+ { listOfType : 'InputValueDefinition' } ,
900
+ { token : '}' } ,
901
+ ] ,
803
902
804
903
InputObjectTypeExtension : [
805
904
{
@@ -817,7 +916,10 @@ const grammar: GraphQLGrammarType = {
817
916
peek : [
818
917
{
819
918
ifCondition : { token : '@' } ,
820
- expect : [ 'Directives' , { ofType : 'InputFieldsDefinition' , optional : true } ] ,
919
+ expect : [
920
+ 'Directives' ,
921
+ { ofType : 'InputFieldsDefinition' , optional : true } ,
922
+ ] ,
821
923
} ,
822
924
{
823
925
ifCondition : { token : '{' } ,
@@ -863,10 +965,18 @@ const grammar: GraphQLGrammarType = {
863
965
} ,
864
966
ExecutableDirectiveLocation : {
865
967
token : 'Name' ,
866
- oneOf : [ 'QUERY' , 'MUTATION' , 'SUBSCRIPTION' , 'FIELD' , 'FRAGMENT_DEFINITION' , 'FRAGMENT_SPREAD' , 'INLINE_FRAGMENT' ] ,
968
+ oneOf : [
969
+ 'QUERY' ,
970
+ 'MUTATION' ,
971
+ 'SUBSCRIPTION' ,
972
+ 'FIELD' ,
973
+ 'FRAGMENT_DEFINITION' ,
974
+ 'FRAGMENT_SPREAD' ,
975
+ 'INLINE_FRAGMENT' ,
976
+ ] ,
867
977
tokenName : 'EnumValue' ,
868
978
} ,
869
- TypeSystemDirectiveLocation : ( {
979
+ TypeSystemDirectiveLocation : {
870
980
token : 'Name' ,
871
981
oneOf : [
872
982
'SCHEMA' ,
@@ -882,7 +992,8 @@ const grammar: GraphQLGrammarType = {
882
992
'INPUT_FIELD_DEFINITION' ,
883
993
] ,
884
994
tokenName : 'EnumValue' ,
885
- } : GraphQLGrammarTokenConstraint ) ,
886
- } ;
995
+ } ,
996
+ // FIXME: enfource proper typing
997
+ } : any ) ;
887
998
888
999
export default grammar ;
0 commit comments