@@ -6,14 +6,15 @@ namespace FSharp.Data.GraphQL.Ast
6
6
7
7
/// 2.2 Query Document
8
8
type Document = {
9
- Definitions: Definition list
10
- }
11
- with
9
+ Definitions : Definition list
10
+ } with
11
+
12
12
member doc.IsEmpty = doc.Definitions.IsEmpty
13
13
14
14
and Definition =
15
15
| OperationDefinition of OperationDefinition
16
16
| FragmentDefinition of FragmentDefinition
17
+
17
18
member x.Name =
18
19
match x with
19
20
| OperationDefinition op -> op.Name
@@ -28,16 +29,19 @@ and Definition =
28
29
| FragmentDefinition frag -> frag.SelectionSet
29
30
30
31
/// 2.2.1 Operations
31
- and OperationDefinition =
32
- {
33
- OperationType : OperationType
34
- Name : string option
35
- VariableDefinitions : VariableDefinition list
36
- Directives : Directive list
37
- SelectionSet : Selection list
38
- }
32
+ and OperationDefinition = {
33
+ OperationType : OperationType
34
+ Name : string option
35
+ VariableDefinitions : VariableDefinition list
36
+ Directives : Directive list
37
+ SelectionSet : Selection list
38
+ } with
39
+
39
40
member x.IsShortHandQuery =
40
- x.OperationType = Query && x.Name.IsNone && x.VariableDefinitions.IsEmpty && x.Directives.IsEmpty
41
+ x.OperationType = Query
42
+ && x.Name.IsNone
43
+ && x.VariableDefinitions.IsEmpty
44
+ && x.Directives.IsEmpty
41
45
42
46
and OperationType =
43
47
| Query
@@ -50,45 +54,40 @@ and Selection =
50
54
| FragmentSpread of FragmentSpread
51
55
/// 2.2.6.2 Inline Fragments
52
56
| InlineFragment of FragmentDefinition
57
+
53
58
member x.Directives =
54
59
match x with
55
60
| Field f -> f.Directives
56
61
| FragmentSpread s -> s.Directives
57
62
| InlineFragment f -> f.Directives
58
63
59
64
/// 2.2.3 Fields
60
- and Field =
61
- {
62
- /// 2.2.5 Field Alias
63
- Alias : string option
64
- Name : string
65
- Arguments : Argument list
66
- Directives : Directive list
67
- SelectionSet : Selection list
68
- }
65
+ and Field = {
66
+ /// 2.2.5 Field Alias
67
+ Alias : string option
68
+ Name : string
69
+ Arguments : Argument list
70
+ Directives : Directive list
71
+ SelectionSet : Selection list
72
+ } with
73
+
69
74
member x.AliasOrName =
70
75
match x.Alias with
71
76
| Some alias -> alias
72
77
| None -> x.Name
73
78
74
79
/// 2.2.4 Arguments
75
- and Argument = {
76
- Name: string
77
- Value: InputValue
78
- }
80
+ and Argument = { Name : string ; Value : InputValue }
79
81
80
82
/// 2.2.6 Fragments
81
- and FragmentSpread = {
82
- Name: string
83
- Directives: Directive list
84
- }
83
+ and FragmentSpread = { Name : string ; Directives : Directive list }
85
84
86
85
and FragmentDefinition = {
87
- Name: string option
86
+ Name : string option
88
87
/// 2.2.6.1 Type Conditions
89
- TypeCondition: string option
90
- Directives: Directive list
91
- SelectionSet: Selection list
88
+ TypeCondition : string option
89
+ Directives : Directive list
90
+ SelectionSet : Selection list
92
91
}
93
92
94
93
/// 2.9 Input Values
@@ -113,79 +112,49 @@ and InputValue =
113
112
| VariableName of string
114
113
115
114
/// 2.2.8 Variables
116
- and VariableDefinition =
117
- { VariableName: string
118
- Type: InputType
119
- DefaultValue: InputValue option }
115
+ and VariableDefinition = { VariableName : string ; Type : InputType ; DefaultValue : InputValue option }
120
116
121
117
/// 2.2.9 Input Types
122
118
and InputType =
123
119
| NamedType of string
124
120
| ListType of InputType
125
121
| NonNullType of InputType
126
- override x.ToString () =
127
- let rec str = function
122
+
123
+ override x.ToString () =
124
+ let rec str =
125
+ function
128
126
| NamedType name -> name
129
127
| ListType inner -> " [" + ( str inner) + " ]"
130
128
| NonNullType inner -> ( str inner) + " !"
131
129
str x
132
130
133
131
/// 2.2.10 Directives
134
- and Directive =
135
- {
136
- Name : string
137
- Arguments : Argument list
138
- }
132
+ and Directive = {
133
+ Name : string
134
+ Arguments : Argument list
135
+ } with
136
+
139
137
member x.If = x.Arguments |> List.find ( fun arg -> arg.Name = " if" )
140
138
141
139
// Type System Definition
142
140
143
- and OperationTypeDefinition = {
144
- Type: string
145
- Operation: OperationType
146
- }
141
+ and OperationTypeDefinition = { Type : string ; Operation : OperationType }
147
142
148
- and SchemaDefintion = {
149
- OperationTypes: OperationTypeDefinition
150
- }
143
+ and SchemaDefintion = { OperationTypes : OperationTypeDefinition }
151
144
152
- and ObjectTypeDefinition = {
153
- Name: string
154
- Interfaces: string []
155
- Fields: FieldDefinition []
156
- }
145
+ and ObjectTypeDefinition = { Name : string ; Interfaces : string []; Fields : FieldDefinition [] }
157
146
158
- and FieldDefinition = {
159
- Name: string
160
- Arguments: InputValueDefinition []
161
- Type: InputType
162
- }
147
+ and FieldDefinition = { Name : string ; Arguments : InputValueDefinition []; Type : InputType }
163
148
164
- and InputValueDefinition = {
165
- Name: string
166
- Type: InputType
167
- DefaultValue: InputValue option
168
- }
149
+ and InputValueDefinition = { Name : string ; Type : InputType ; DefaultValue : InputValue option }
169
150
170
- and InterfaceTypeDefinition = {
171
- Name: string
172
- Fields: FieldDefinition []
173
- }
151
+ and InterfaceTypeDefinition = { Name : string ; Fields : FieldDefinition [] }
174
152
175
- and UnionTypeDefinition = {
176
- Name: string
177
- Types: string []
178
- }
153
+ and UnionTypeDefinition = { Name : string ; Types : string [] }
179
154
180
- and EnumTypeDefinition = {
181
- Name: string
182
- Values: string []
183
- }
155
+ and EnumTypeDefinition = { Name : string ; Values : string [] }
184
156
185
- and InputObjectTypeDefinition = {
186
- Name: string
187
- Fields: InputValueDefinition []
188
- }
157
+ and InputObjectTypeDefinition = { Name : string ; Fields : InputValueDefinition [] }
189
158
190
159
and TypeDefinition =
191
160
| ScalarTypeDefinition of string
@@ -194,4 +163,3 @@ and TypeDefinition =
194
163
| UnionTypeDefinition of UnionTypeDefinition
195
164
| EnumTypeDefinition of EnumTypeDefinition
196
165
| InputObjectTypeDefinition of InputObjectTypeDefinition
197
-
0 commit comments