@@ -14,11 +14,12 @@ import {
14
14
SelectionSetNode ,
15
15
StringValueNode ,
16
16
ValueNode ,
17
+ Kind ,
17
18
} from "graphql"
18
19
19
20
export function document ( definitions : DefinitionNode [ ] ) : DocumentNode {
20
21
return {
21
- kind : "Document" ,
22
+ kind : Kind . DOCUMENT ,
22
23
definitions,
23
24
}
24
25
}
@@ -29,7 +30,7 @@ export function fragmentDefinition(
29
30
selections : SelectionNode [ ]
30
31
) : FragmentDefinitionNode {
31
32
return {
32
- kind : "FragmentDefinition" ,
33
+ kind : Kind . FRAGMENT_DEFINITION ,
33
34
name : name ( fragmentName ?? typeName ) ,
34
35
typeCondition : namedType ( typeName ) ,
35
36
selectionSet : selectionSet ( selections ) ,
@@ -41,7 +42,7 @@ export function inlineFragment(
41
42
selections : readonly SelectionNode [ ]
42
43
) : InlineFragmentNode {
43
44
return {
44
- kind : "InlineFragment" ,
45
+ kind : Kind . INLINE_FRAGMENT ,
45
46
typeCondition : namedType ( typeCondition ) ,
46
47
selectionSet : selectionSet ( selections ) ,
47
48
}
@@ -51,7 +52,7 @@ export function selectionSet(
51
52
selections : readonly SelectionNode [ ] = [ ]
52
53
) : SelectionSetNode {
53
54
return {
54
- kind : "SelectionSet" ,
55
+ kind : Kind . SELECTION_SET ,
55
56
selections : selections ,
56
57
}
57
58
}
@@ -64,7 +65,7 @@ export function field(
64
65
directives ?: DirectiveNode [ ]
65
66
) : FieldNode {
66
67
return {
67
- kind : "Field" ,
68
+ kind : Kind . FIELD ,
68
69
name : name ( fieldName ) ,
69
70
alias : alias ? name ( alias ) : undefined ,
70
71
arguments : args ,
@@ -75,29 +76,29 @@ export function field(
75
76
76
77
export function arg ( argName : string , value : ValueNode ) : ArgumentNode {
77
78
return {
78
- kind : "Argument" ,
79
+ kind : Kind . ARGUMENT ,
79
80
name : name ( argName ) ,
80
81
value,
81
82
}
82
83
}
83
84
84
85
export function name ( value : string ) : NameNode {
85
86
return {
86
- kind : "Name" ,
87
+ kind : Kind . NAME ,
87
88
value : value ,
88
89
}
89
90
}
90
91
91
92
export function namedType ( typeName : string ) : NamedTypeNode {
92
93
return {
93
- kind : "NamedType" ,
94
+ kind : Kind . NAMED_TYPE ,
94
95
name : name ( typeName ) ,
95
96
}
96
97
}
97
98
98
99
export function fragmentSpread ( fragmentName : string ) : FragmentSpreadNode {
99
100
return {
100
- kind : "FragmentSpread" ,
101
+ kind : Kind . FRAGMENT_SPREAD ,
101
102
name : name ( fragmentName ) ,
102
103
}
103
104
}
@@ -107,7 +108,7 @@ export function directive(
107
108
args ?: ArgumentNode [ ]
108
109
) : DirectiveNode {
109
110
return {
110
- kind : "Directive" ,
111
+ kind : Kind . DIRECTIVE ,
111
112
name : name ( directiveName ) ,
112
113
arguments : args ,
113
114
}
@@ -119,14 +120,14 @@ export function skipDirective(condition: boolean = true) {
119
120
120
121
export function boolValue ( value : boolean ) : BooleanValueNode {
121
122
return {
122
- kind : "BooleanValue" ,
123
+ kind : Kind . BOOLEAN ,
123
124
value,
124
125
}
125
126
}
126
127
127
128
export function stringValue ( value : string ) : StringValueNode {
128
129
return {
129
- kind : "StringValue" ,
130
+ kind : Kind . STRING ,
130
131
value,
131
132
}
132
133
}
0 commit comments