@@ -27,6 +27,7 @@ type Dog implements Pet {
27
27
barkVolume: Int
28
28
doesKnowCommand(dogCommand: DogCommand!) : Boolean!
29
29
isHousetrained(atOtherHomes: Boolean): Boolean!
30
+ owner: Human
30
31
}
31
32
32
33
interface Sentient {
@@ -46,15 +47,22 @@ type Human implements Sentient {
46
47
name: String!
47
48
}
48
49
50
+ enum CatCommand { JUMP }
51
+
49
52
type Cat implements Pet {
50
53
name: String!
51
54
nickname: String
55
+ doesKnowCommand(catCommand: CatCommand!) : Boolean!
52
56
meowVolume: Int
53
57
}
54
58
55
59
union CatOrDog = Cat | Dog
56
60
union DogOrHuman = Dog | Human
57
61
union HumanOrAlien = Human | Alien
62
+
63
+ type QueryRoot {
64
+ dog: Dog
65
+ }
58
66
```
59
67
60
68
## Operations
@@ -378,10 +386,10 @@ Conversely the leaf field selections of GraphQL queries
378
386
must be scalars. Leaf selections on objects, interfaces,
379
387
and unions without subfields are disallowed.
380
388
381
- Let's assume the following query root type of the schema:
389
+ Let's assume the following additions to the query root type of the schema:
382
390
383
391
```
384
- type QueryRoot {
392
+ extend type QueryRoot {
385
393
human: Human
386
394
pet: Pet
387
395
catOrDog: CatOrDog
@@ -456,11 +464,16 @@ to our type system:
456
464
457
465
```
458
466
type Arguments {
459
- multipleReqs(x: Int!, y: Int!)
460
- booleanArgField(booleanArg: Boolean)
461
- floatArgField(floatArg: Float)
462
- intArgField(intArg: Int)
463
- nonNullBooleanArgField(nonNullBooleanArg: Boolean!)
467
+ multipleReqs(x: Int!, y: Int!): Int!
468
+ booleanArgField(booleanArg: Boolean): Boolean
469
+ floatArgField(floatArg: Float): Float
470
+ intArgField(intArg: Int): Int
471
+ nonNullBooleanArgField(nonNullBooleanArg: Boolean!): Boolean!
472
+ booleanListArgField(booleanListArg: [Boolean]!): [Boolean]
473
+ }
474
+
475
+ extend type QueryRoot {
476
+ arguments: Arguments
464
477
}
465
478
```
466
479
@@ -601,8 +614,10 @@ For example the following document is valid:
601
614
602
615
``` graphql
603
616
{
604
- ... fragmentOne
605
- ... fragmentTwo
617
+ dog {
618
+ ... fragmentOne
619
+ ... fragmentTwo
620
+ }
606
621
}
607
622
608
623
fragment fragmentOne on Dog {
@@ -620,7 +635,9 @@ While this document is invalid:
620
635
621
636
``` !graphql
622
637
{
623
- ...fragmentOne
638
+ dog {
639
+ ...fragmentOne
640
+ }
624
641
}
625
642
626
643
fragment fragmentOne on Dog {
@@ -661,7 +678,7 @@ fragment inlineFragment on Dog {
661
678
}
662
679
}
663
680
664
- fragment inlineFragment on Dog {
681
+ fragment inlineFragment2 on Dog {
665
682
... @include (if : true ) {
666
683
name
667
684
}
@@ -826,7 +843,7 @@ fragment barkVolumeFragment on Dog {
826
843
827
844
If the above fragments were inlined, this would result in the infinitely large:
828
845
829
- ``` ! graphql
846
+ ``` graphql
830
847
{
831
848
dog {
832
849
name
@@ -870,7 +887,7 @@ fragment ownerFragment on Dog {
870
887
871
888
** Formal Specification **
872
889
873
- * For each {spread} (named or inline) in defined in the document.
890
+ * For each {spread} (named or inline) defined in the document.
874
891
* Let {fragment} be the target of {spread}
875
892
* Let {fragmentType} be the type condition of {fragment}
876
893
* Let {parentType} be the type of the selection set containing {spread}
@@ -893,7 +910,7 @@ the parent type.
893
910
894
911
##### Object Spreads In Object Scope
895
912
896
- In the scope of a object type, the only valid object type
913
+ In the scope of an object type, the only valid object type
897
914
fragment spread is one that applies to the same type that
898
915
is in scope.
899
916
@@ -946,7 +963,7 @@ fragment catOrDogNameFragment on CatOrDog {
946
963
}
947
964
948
965
fragment unionWithObjectFragment on Dog {
949
- ... CatOrDogFragment
966
+ ... catOrDogNameFragment
950
967
}
951
968
```
952
969
@@ -1083,11 +1100,9 @@ For example the following query will not pass validation.
1083
1100
GraphQL servers define what directives they support. For each
1084
1101
usage of a directive, the directive must be available on that server.
1085
1102
1086
- ## Operations
1087
-
1088
- ### Variables
1103
+ ## Variables
1089
1104
1090
- #### Variable Default Values Are Correctly Typed
1105
+ ### Variable Default Values Are Correctly Typed
1091
1106
1092
1107
** Formal Specification **
1093
1108
@@ -1100,8 +1115,8 @@ usage of a directive, the directive must be available on that server.
1100
1115
1101
1116
** Explanatory Text **
1102
1117
1103
- Variable defined by operations are allowed to define default values
1104
- if the type of that variable not non-null.
1118
+ Variables defined by operations are allowed to define default values
1119
+ if the type of that variable is not non-null.
1105
1120
1106
1121
For example the following query will pass validation.
1107
1122
@@ -1150,7 +1165,7 @@ query intToFloatQuery($floatVar: Float = 1) {
1150
1165
}
1151
1166
```
1152
1167
1153
- #### Variables Are Input Types
1168
+ ### Variables Are Input Types
1154
1169
1155
1170
** Formal Specification **
1156
1171
@@ -1167,19 +1182,34 @@ Variables can only be scalars, enums, input objects, or lists and non-null
1167
1182
variants of those types. These are known as input types. Object, unions,
1168
1183
and interfaces cannot be used as inputs.
1169
1184
1185
+ For these examples, consider the following typesystem additions:
1186
+
1187
+ ```
1188
+ input ComplexInput { name: String, owner: String }
1189
+
1190
+ extend type QueryRoot {
1191
+ findDog(complex: ComplexInput): Dog
1192
+ booleanList(booleanListArg: [Boolean!]): Boolean
1193
+ }
1194
+ ```
1195
+
1170
1196
The following queries are valid:
1171
1197
1172
1198
``` graphql
1173
1199
query takesBoolean ($atOtherHomes : Boolean ) {
1174
- # ...
1200
+ dog {
1201
+ isHousetrained (atOtherHomes : $atOtherHomes )
1202
+ }
1175
1203
}
1176
1204
1177
1205
query takesComplexInput ($complexInput : ComplexInput ) {
1178
- # ...
1206
+ findDog (complex : $complexInput ) {
1207
+ name
1208
+ }
1179
1209
}
1180
1210
1181
1211
query TakesListOfBooleanBang ($booleans : [Boolean ! ]) {
1182
- # ...
1212
+ booleanList ( booleanListArg : $booleans )
1183
1213
}
1184
1214
```
1185
1215
@@ -1203,7 +1233,7 @@ query takesCatOrDog($catOrDog: CatOrDog) {
1203
1233
}
1204
1234
```
1205
1235
1206
- #### All Variable Uses Defined
1236
+ ### All Variable Uses Defined
1207
1237
1208
1238
** Formal Specification **
1209
1239
@@ -1345,7 +1375,7 @@ This is because {housetrainedQueryTwoNotDefined} does not define
1345
1375
a variable ${atOtherHomes} but that variable is used by {isHousetrainedFragment}
1346
1376
which is included in that operation.
1347
1377
1348
- #### All Variables Used
1378
+ ### All Variables Used
1349
1379
1350
1380
** Formal Specification **
1351
1381
@@ -1427,7 +1457,7 @@ fragment isHousetrainedFragment on Dog {
1427
1457
This document is not valid because {queryWithExtraVar} defines
1428
1458
an extraneous variable.
1429
1459
1430
- #### All Variable Usages are Allowed
1460
+ ### All Variable Usages are Allowed
1431
1461
1432
1462
** Formal Specification **
1433
1463
0 commit comments