@@ -6,14 +6,15 @@ namespace FSharp.Data.GraphQL.Ast
66
77/// 2.2 Query Document
88type Document = {
9- Definitions: Definition list
10- }
11- with
9+ Definitions : Definition list
10+ } with
11+
1212 member doc.IsEmpty = doc.Definitions.IsEmpty
1313
1414and Definition =
1515 | OperationDefinition of OperationDefinition
1616 | FragmentDefinition of FragmentDefinition
17+
1718 member x.Name =
1819 match x with
1920 | OperationDefinition op -> op.Name
@@ -28,16 +29,19 @@ and Definition =
2829 | FragmentDefinition frag -> frag.SelectionSet
2930
3031/// 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+
3940 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
4145
4246and OperationType =
4347 | Query
@@ -50,45 +54,40 @@ and Selection =
5054 | FragmentSpread of FragmentSpread
5155 /// 2.2.6.2 Inline Fragments
5256 | InlineFragment of FragmentDefinition
57+
5358 member x.Directives =
5459 match x with
5560 | Field f -> f.Directives
5661 | FragmentSpread s -> s.Directives
5762 | InlineFragment f -> f.Directives
5863
5964/// 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+
6974 member x.AliasOrName =
7075 match x.Alias with
7176 | Some alias -> alias
7277 | None -> x.Name
7378
7479/// 2.2.4 Arguments
75- and Argument = {
76- Name: string
77- Value: InputValue
78- }
80+ and Argument = { Name : string ; Value : InputValue }
7981
8082/// 2.2.6 Fragments
81- and FragmentSpread = {
82- Name: string
83- Directives: Directive list
84- }
83+ and FragmentSpread = { Name : string ; Directives : Directive list }
8584
8685and FragmentDefinition = {
87- Name: string option
86+ Name : string option
8887 /// 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
9291}
9392
9493/// 2.9 Input Values
@@ -113,79 +112,49 @@ and InputValue =
113112 | VariableName of string
114113
115114/// 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 }
120116
121117/// 2.2.9 Input Types
122118and InputType =
123119 | NamedType of string
124120 | ListType of InputType
125121 | NonNullType of InputType
126- override x.ToString () =
127- let rec str = function
122+
123+ override x.ToString () =
124+ let rec str =
125+ function
128126 | NamedType name -> name
129127 | ListType inner -> " [" + ( str inner) + " ]"
130128 | NonNullType inner -> ( str inner) + " !"
131129 str x
132130
133131/// 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+
139137 member x.If = x.Arguments |> List.find ( fun arg -> arg.Name = " if" )
140138
141139// Type System Definition
142140
143- and OperationTypeDefinition = {
144- Type: string
145- Operation: OperationType
146- }
141+ and OperationTypeDefinition = { Type : string ; Operation : OperationType }
147142
148- and SchemaDefintion = {
149- OperationTypes: OperationTypeDefinition
150- }
143+ and SchemaDefintion = { OperationTypes : OperationTypeDefinition }
151144
152- and ObjectTypeDefinition = {
153- Name: string
154- Interfaces: string []
155- Fields: FieldDefinition []
156- }
145+ and ObjectTypeDefinition = { Name : string ; Interfaces : string []; Fields : FieldDefinition [] }
157146
158- and FieldDefinition = {
159- Name: string
160- Arguments: InputValueDefinition []
161- Type: InputType
162- }
147+ and FieldDefinition = { Name : string ; Arguments : InputValueDefinition []; Type : InputType }
163148
164- and InputValueDefinition = {
165- Name: string
166- Type: InputType
167- DefaultValue: InputValue option
168- }
149+ and InputValueDefinition = { Name : string ; Type : InputType ; DefaultValue : InputValue option }
169150
170- and InterfaceTypeDefinition = {
171- Name: string
172- Fields: FieldDefinition []
173- }
151+ and InterfaceTypeDefinition = { Name : string ; Fields : FieldDefinition [] }
174152
175- and UnionTypeDefinition = {
176- Name: string
177- Types: string []
178- }
153+ and UnionTypeDefinition = { Name : string ; Types : string [] }
179154
180- and EnumTypeDefinition = {
181- Name: string
182- Values: string []
183- }
155+ and EnumTypeDefinition = { Name : string ; Values : string [] }
184156
185- and InputObjectTypeDefinition = {
186- Name: string
187- Fields: InputValueDefinition []
188- }
157+ and InputObjectTypeDefinition = { Name : string ; Fields : InputValueDefinition [] }
189158
190159and TypeDefinition =
191160 | ScalarTypeDefinition of string
@@ -194,4 +163,3 @@ and TypeDefinition =
194163 | UnionTypeDefinition of UnionTypeDefinition
195164 | EnumTypeDefinition of EnumTypeDefinition
196165 | InputObjectTypeDefinition of InputObjectTypeDefinition
197-
0 commit comments