-
Notifications
You must be signed in to change notification settings - Fork 221
/
QueryAst.scala
783 lines (693 loc) · 23.5 KB
/
QueryAst.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
package sangria.ast
import scala.collection.immutable.ListMap
/** A complete GraphQL request operated on by a GraphQL service.
*
* @param definitions
* The definitions, which primarily constitute the document.
*
* @see
* [[https://spec.graphql.org/June2018/#Document]]
*/
case class Document(
definitions: Vector[Definition],
override val trailingComments: Vector[Comment] = Vector.empty,
override val location: Option[AstLocation] = None,
sourceMapper: Option[SourceMapper] = None)
extends AstNode
with WithTrailingComments {
/** Map of operation name to its definition. */
lazy val operations: Map[Option[String], OperationDefinition] = Map(definitions.collect {
case op: OperationDefinition =>
op.name -> op
}: _*)
/** Map of fragment name to its definition. */
lazy val fragments: Map[String, FragmentDefinition] = Map(definitions.collect {
case fragment: FragmentDefinition =>
fragment.name -> fragment
}: _*)
lazy val source: Option[String] = sourceMapper.map(_.source)
def operationType(operationName: Option[String] = None): Option[OperationType] =
operation(operationName).map(_.operationType)
/** Return the operation for the given name.
*
* @return
* `None`, if no operations are defined or if the given name is ambiguous
*/
def operation(operationName: Option[String] = None): Option[OperationDefinition] =
if (operationName.isEmpty && operations.size != 1)
None
else if (operationName.isEmpty && operations.size == 1)
Some(operations.head._2)
else
operationName
.flatMap(opName => operations.get(Some(opName)))
.orElse(
operations.values.headOption
) // FIXME This appears to return the first operation if the named one doesn't exist?
def withoutSourceMapper: Document = copy(sourceMapper = None)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Document]
/** Merges two documents. The `sourceMapper`s are combined. */
def merge(other: Document): Document = Document.merge(Vector(this, other))
/** An alias for `merge`
*/
def +(other: Document): Document = merge(other)
override def equals(other: Any): Boolean = other match {
case that: Document =>
that.canEqual(this) &&
definitions == that.definitions &&
location == that.location
case _ => false
}
private[this] lazy val hash =
Seq(definitions, location).map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
override def hashCode(): Int = hash
}
object Document {
/** Provided a collection of ASTs, presumably each from different files, concatenate the ASTs
* together into batched AST, useful for validating many GraphQL source files which together
* represent one conceptual application.
*
* The result `Document` will retain correlation to the original `sourceMapper`s.
*/
def merge(documents: Traversable[Document]): Document = {
val originalSourceMappers = documents.flatMap(_.sourceMapper).toVector
val sourceMapper =
if (originalSourceMappers.nonEmpty) Some(AggregateSourceMapper.merge(originalSourceMappers))
else None
Document(documents.toVector.flatMap(_.definitions), sourceMapper = sourceMapper)
}
/** The most basic, but valid document with a stub `Query` type
*/
val emptyStub: Document =
Document(
Vector(
ObjectTypeDefinition(
"Query",
Vector.empty,
Vector(FieldDefinition("stub", NamedType("String"), Vector.empty)))))
}
case class InputDocument(
values: Vector[Value],
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None,
sourceMapper: Option[SourceMapper] = None)
extends AstNode
with WithTrailingComments {
lazy val source: Option[String] = sourceMapper.map(_.source)
/** Merges two documents. The `sourceMapper` is lost along the way.
*/
def merge(other: InputDocument): InputDocument = InputDocument.merge(Vector(this, other))
/** An alias for `merge`
*/
def +(other: InputDocument): InputDocument = merge(other)
override def equals(other: Any): Boolean = other match {
case that: InputDocument =>
that.canEqual(this) &&
values == that.values &&
location == that.location
case _ => false
}
override def hashCode(): Int =
Seq(values, location).map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
}
object InputDocument {
def merge(documents: Iterable[InputDocument]): InputDocument =
InputDocument(documents.toVector.flatMap(_.values))
}
sealed trait ConditionalFragment extends AstNode {
def typeConditionOpt: Option[NamedType]
}
sealed trait WithComments extends AstNode {
def comments: Vector[Comment]
}
sealed trait WithDescription extends AstNode {
def description: Option[StringValue]
}
sealed trait WithTrailingComments {
def trailingComments: Vector[Comment]
}
/** A GraphQL AST node that contains [[Selection selections]].
*
* Most typically, this is a [[Field field]] that is of a composite type.
*/
sealed trait SelectionContainer extends AstNode with WithComments with WithTrailingComments {
/** The selection set contained within this node, if any. */
def selections: Vector[Selection]
def location: Option[AstLocation]
}
/** A definition in a [[Document GraphQL document]].
*
* A GraphQL document consists primarily of definitions, which are either executable or
* representative of a GraphQL type system. The executable definitions are
* [[OperationDefinition operation]] and [[FragmentDefinition fragment definitions]]; those that
* represent a type system fall into [[TypeSystemDefinition definition]] or
* [[TypeSystemExtensionDefinition extension]] categories.
*
* @see
* [[https://spec.graphql.org/June2018/#Definition]]
*/
sealed trait Definition extends AstNode
/** A definition of a GraphQL operation.
*
* Every GraphQL request invokes a specific operation, possibly with values to substitute into the
* operation's variables.
*
* @param name
* The name of the operation. Optional only if there is only one operation in the
* [[Document document]]. Used for selecting the specific operation to invoke in a GraphQL
* request.
* @param variables
* The variables that must be substituted into the operation. Values for these must be provided
* either by their defaults or with the GraphQL request.
*
* @see
* [[https://spec.graphql.org/June2018/#OperationDefinition]]
*/
case class OperationDefinition(
operationType: OperationType = OperationType.Query,
name: Option[String] = None,
variables: Vector[VariableDefinition] = Vector.empty,
override val directives: Vector[Directive] = Vector.empty,
override val selections: Vector[Selection],
override val comments: Vector[Comment] = Vector.empty,
override val trailingComments: Vector[Comment] = Vector.empty,
override val location: Option[AstLocation] = None)
extends Definition
with WithDirectives
with SelectionContainer
case class FragmentDefinition(
name: String,
typeCondition: NamedType,
directives: Vector[Directive],
selections: Vector[Selection],
variables: Vector[VariableDefinition] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Definition
with ConditionalFragment
with WithDirectives
with SelectionContainer {
lazy val typeConditionOpt: Option[NamedType] = Some(typeCondition)
}
/** A definition of a variable to an [[OperationDefinition operation]].
*
* @param name
* Name of the variable being defined.
* @param defaultValue
* Value that the variable should assume in an operation if none was provided with the GraphQL
* request.
*
* @see
* [[https://spec.graphql.org/June2018/#VariableDefinition]]
*/
case class VariableDefinition(
name: String,
tpe: Type,
defaultValue: Option[Value],
override val directives: Vector[Directive] = Vector.empty,
override val comments: Vector[Comment] = Vector.empty,
override val location: Option[AstLocation] = None)
extends AstNode
with WithComments
with WithDirectives
sealed trait Type extends AstNode {
def namedType: NamedType = {
@annotation.tailrec
def loop(tpe: Type): NamedType = tpe match {
case NotNullType(ofType, _) => loop(ofType)
case ListType(ofType, _) => loop(ofType)
case named: NamedType => named
}
loop(this)
}
}
case class NamedType(name: String, location: Option[AstLocation] = None) extends Type
case class NotNullType(ofType: Type, location: Option[AstLocation] = None) extends Type
case class ListType(ofType: Type, location: Option[AstLocation] = None) extends Type
sealed trait WithArguments extends AstNode {
def arguments: Vector[Argument]
}
/** A component of information to be queried and returned.
*
* Most typically a selection is a [[Field field]].
*
* @see
* [[https://spec.graphql.org/June2018/#Selection]]
*/
sealed trait Selection extends AstNode with WithDirectives with WithComments
/** @see
* [[https://spec.graphql.org/June2018/#sec-Language.Fields]]
*/
case class Field(
alias: Option[String],
name: String,
arguments: Vector[Argument],
directives: Vector[Directive],
override val selections: Vector[Selection],
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Selection
with SelectionContainer
with WithArguments {
lazy val outputName: String = alias.getOrElse(name)
}
case class FragmentSpread(
name: String,
directives: Vector[Directive],
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Selection
case class InlineFragment(
typeCondition: Option[NamedType],
directives: Vector[Directive],
selections: Vector[Selection],
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Selection
with ConditionalFragment
with SelectionContainer {
def typeConditionOpt: Option[NamedType] = typeCondition
}
sealed trait NameValue extends AstNode with WithComments {
def name: String
def value: Value
}
sealed trait WithDirectives extends AstNode {
def directives: Vector[Directive]
}
case class Directive(
name: String,
arguments: Vector[Argument],
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends AstNode
with WithArguments
case class Argument(
name: String,
value: Value,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends NameValue
/** A value that can be substituted into a GraphQL operation [[VariableDefinition variable]].
*
* Called "input values" in the GraphQL spec. Input values can be [[ScalarValue scalars]],
* [[EnumValue enumeration values]], [[ListValue lists]], [[ObjectValue objects]], or
* [[NullValue null values]].
*
* @see
* [[https://spec.graphql.org/June2018/#Value]]
* @group value
*/
sealed trait Value extends AstNode with WithComments
/** @group scalar
*/
sealed trait ScalarValue extends Value
/** @group scalar
*/
case class IntValue(
value: Int,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group scalar
*/
case class BigIntValue(
value: BigInt,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group scalar
*/
case class FloatValue(
value: Double,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group scalar
*/
case class BigDecimalValue(
value: BigDecimal,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group scalar
*/
case class StringValue(
value: String,
block: Boolean = false,
blockRawValue: Option[String] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group scalar
*/
case class BooleanValue(
value: Boolean,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ScalarValue
/** @group value
*/
case class EnumValue(
value: String,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Value
/** @group value
*/
case class ListValue(
values: Vector[Value],
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Value
/** @group value
*/
case class VariableValue(
name: String,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Value
/** @group value
*/
case class NullValue(comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None)
extends Value
/** @group value
*/
case class ObjectValue(
fields: Vector[ObjectField],
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends Value {
lazy val fieldsByName: Map[String, Value] =
fields.foldLeft(ListMap.empty[String, Value]) { case (acc, field) =>
acc + (field.name -> field.value)
}
}
/** @group value
*/
object ObjectValue {
def apply(fields: (String, Value)*): ObjectValue = ObjectValue(
fields.toVector.map(f => ObjectField(f._1, f._2)))
}
case class ObjectField(
name: String,
value: Value,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends NameValue
case class Comment(text: String, location: Option[AstLocation] = None) extends AstNode
// Schema Definition
/** @group typesystem
*/
case class ScalarTypeDefinition(
name: String,
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithDescription {
def rename(newName: String): ScalarTypeDefinition = copy(name = newName)
}
/** @see
* [[https://spec.graphql.org/June2018/#FieldDefinition]]
* @group typesystem
*/
case class FieldDefinition(
name: String,
fieldType: Type,
arguments: Vector[InputValueDefinition],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends SchemaAstNode
with WithDirectives
with WithDescription
/** @group typesystem
*/
case class InputValueDefinition(
name: String,
valueType: Type,
defaultValue: Option[Value],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends SchemaAstNode
with WithDirectives
with WithDescription
/** @see
* [[https://spec.graphql.org/June2018/#sec-Objects]]
* @group typesystem
*/
case class ObjectTypeDefinition(
name: String,
interfaces: Vector[NamedType],
fields: Vector[FieldDefinition],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithTrailingComments
with WithDescription {
def rename(newName: String): ObjectTypeDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class InterfaceTypeDefinition(
name: String,
fields: Vector[FieldDefinition],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithTrailingComments
with WithDescription {
def rename(newName: String): InterfaceTypeDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class UnionTypeDefinition(
name: String,
types: Vector[NamedType],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithDescription {
def rename(newName: String): UnionTypeDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class EnumTypeDefinition(
name: String,
values: Vector[EnumValueDefinition],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithTrailingComments
with WithDescription {
def rename(newName: String): EnumTypeDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class EnumValueDefinition(
name: String,
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends SchemaAstNode
with WithDirectives
with WithDescription
/** @group typesystem
*/
case class InputObjectTypeDefinition(
name: String,
fields: Vector[InputValueDefinition],
directives: Vector[Directive] = Vector.empty,
description: Option[StringValue] = None,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeDefinition
with WithTrailingComments
with WithDescription {
def rename(newName: String): InputObjectTypeDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class ObjectTypeExtensionDefinition(
name: String,
interfaces: Vector[NamedType],
fields: Vector[FieldDefinition],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ObjectLikeTypeExtensionDefinition
with WithTrailingComments {
def rename(newName: String): ObjectTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class InterfaceTypeExtensionDefinition(
name: String,
fields: Vector[FieldDefinition],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends ObjectLikeTypeExtensionDefinition
with WithTrailingComments {
def rename(newName: String): InterfaceTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class InputObjectTypeExtensionDefinition(
name: String,
fields: Vector[InputValueDefinition],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeExtensionDefinition
with WithTrailingComments {
def rename(newName: String): InputObjectTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class EnumTypeExtensionDefinition(
name: String,
values: Vector[EnumValueDefinition],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeExtensionDefinition
with WithTrailingComments {
def rename(newName: String): EnumTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class UnionTypeExtensionDefinition(
name: String,
types: Vector[NamedType],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeExtensionDefinition {
def rename(newName: String): UnionTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class ScalarTypeExtensionDefinition(
name: String,
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeExtensionDefinition {
def rename(newName: String): ScalarTypeExtensionDefinition = copy(name = newName)
}
/** @group typesystem
*/
case class SchemaExtensionDefinition(
operationTypes: Vector[OperationTypeDefinition],
directives: Vector[Directive] = Vector.empty,
comments: Vector[Comment] = Vector.empty,
trailingComments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeSystemExtensionDefinition
with WithDirectives
with WithTrailingComments
/** @group typesystem
*/
case class DirectiveDefinition(
name: String,
arguments: Vector[InputValueDefinition],
locations: Vector[DirectiveLocation],
description: Option[StringValue] = None,
repeatable: Boolean = false,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends TypeSystemDefinition
with WithDescription
/** @group typesystem
*/
case class DirectiveLocation(
name: String,
comments: Vector[Comment] = Vector.empty,
location: Option[AstLocation] = None)
extends SchemaAstNode
/** A definition of a GraphQL schema.
*
* @param operationTypes
* The [[https://spec.graphql.org/June2018/#RootOperationTypeDefinition root operations]]
* available in this schema.
* @see
* [[https://spec.graphql.org/June2018/#sec-Schema]]
* @group typesystem
*/
case class SchemaDefinition(
operationTypes: Vector[OperationTypeDefinition],
override val directives: Vector[Directive] = Vector.empty,
override val description: Option[StringValue] = None,
override val comments: Vector[Comment] = Vector.empty,
override val trailingComments: Vector[Comment] = Vector.empty,
override val location: Option[AstLocation] = None)
extends TypeSystemDefinition
with WithDescription
with WithTrailingComments
with WithDirectives
/** @group typesystem
*/
case class OperationTypeDefinition(
operation: OperationType,
tpe: NamedType,
override val comments: Vector[Comment] = Vector.empty,
override val location: Option[AstLocation] = None)
extends SchemaAstNode
/** A node in the AST of a parsed GraphQL request document. */
sealed trait AstNode {
/** Location at which this node lexically begins in the GraphQL request source code. */
def location: Option[AstLocation]
def cacheKeyHash: Int = System.identityHashCode(this)
}
/** @group typesystem
*/
sealed trait SchemaAstNode extends AstNode with WithComments
/** @group typesystem
*/
sealed trait TypeSystemDefinition extends SchemaAstNode with Definition
/** @group typesystem
*/
sealed trait TypeSystemExtensionDefinition extends SchemaAstNode with Definition
/** @group typesystem
*/
sealed trait TypeDefinition extends TypeSystemDefinition with WithDirectives with WithDescription {
def name: String
def rename(newName: String): TypeDefinition
}
/** @group typesystem
*/
sealed trait TypeExtensionDefinition extends TypeSystemExtensionDefinition with WithDirectives {
def name: String
def rename(newName: String): TypeExtensionDefinition
}
/** @group typesystem
*/
sealed trait ObjectLikeTypeExtensionDefinition extends TypeExtensionDefinition {
def fields: Vector[FieldDefinition]
}