Skip to content

Commit 9f4c839

Browse files
committed
Merge pull request #139 from nuance/validation-fixes
Fix a few issues with the validation tests
2 parents 2a28eaa + b99950b commit 9f4c839

File tree

1 file changed

+48
-16
lines changed

1 file changed

+48
-16
lines changed

spec/Section 5 -- Validation.md

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Dog implements Pet {
2727
barkVolume: Int
2828
doesKnowCommand(dogCommand: DogCommand!) : Boolean!
2929
isHousetrained(atOtherHomes: Boolean): Boolean!
30+
owner: Human
3031
}
3132
3233
interface Sentient {
@@ -46,15 +47,22 @@ type Human implements Sentient {
4647
name: String!
4748
}
4849
50+
enum CatCommand { JUMP }
51+
4952
type Cat implements Pet {
5053
name: String!
5154
nickname: String
55+
doesKnowCommand(catCommand: CatCommand!) : Boolean!
5256
meowVolume: Int
5357
}
5458
5559
union CatOrDog = Cat | Dog
5660
union DogOrHuman = Dog | Human
5761
union HumanOrAlien = Human | Alien
62+
63+
type QueryRoot {
64+
dog: Dog
65+
}
5866
```
5967

6068
## Operations
@@ -378,10 +386,10 @@ Conversely the leaf field selections of GraphQL queries
378386
must be scalars. Leaf selections on objects, interfaces,
379387
and unions without subfields are disallowed.
380388

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:
382390

383391
```
384-
type QueryRoot {
392+
extend type QueryRoot {
385393
human: Human
386394
pet: Pet
387395
catOrDog: CatOrDog
@@ -456,11 +464,16 @@ to our type system:
456464

457465
```
458466
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
464477
}
465478
```
466479

@@ -601,8 +614,10 @@ For example the following document is valid:
601614

602615
```graphql
603616
{
604-
...fragmentOne
605-
...fragmentTwo
617+
dog {
618+
...fragmentOne
619+
...fragmentTwo
620+
}
606621
}
607622

608623
fragment fragmentOne on Dog {
@@ -620,7 +635,9 @@ While this document is invalid:
620635

621636
```!graphql
622637
{
623-
...fragmentOne
638+
dog {
639+
...fragmentOne
640+
}
624641
}
625642
626643
fragment fragmentOne on Dog {
@@ -661,7 +678,7 @@ fragment inlineFragment on Dog {
661678
}
662679
}
663680

664-
fragment inlineFragment on Dog {
681+
fragment inlineFragment2 on Dog {
665682
... @include(if: true) {
666683
name
667684
}
@@ -826,7 +843,7 @@ fragment barkVolumeFragment on Dog {
826843

827844
If the above fragments were inlined, this would result in the infinitely large:
828845

829-
```!graphql
846+
```graphql
830847
{
831848
dog {
832849
name
@@ -946,7 +963,7 @@ fragment catOrDogNameFragment on CatOrDog {
946963
}
947964

948965
fragment unionWithObjectFragment on Dog {
949-
...CatOrDogFragment
966+
...catOrDogNameFragment
950967
}
951968
```
952969

@@ -1167,19 +1184,34 @@ Variables can only be scalars, enums, input objects, or lists and non-null
11671184
variants of those types. These are known as input types. Object, unions,
11681185
and interfaces cannot be used as inputs.
11691186

1187+
For these examples, consider the following typesystem additions:
1188+
1189+
```
1190+
input ComplexInput { name: String, owner: String }
1191+
1192+
extend type QueryRoot {
1193+
findDog(complex: ComplexInput): Dog
1194+
booleanList(booleanListArg: [Boolean!]): Boolean
1195+
}
1196+
```
1197+
11701198
The following queries are valid:
11711199

11721200
```graphql
11731201
query takesBoolean($atOtherHomes: Boolean) {
1174-
# ...
1202+
dog {
1203+
isHousetrained(atOtherHomes: $atOtherHomes)
1204+
}
11751205
}
11761206

11771207
query takesComplexInput($complexInput: ComplexInput) {
1178-
# ...
1208+
findDog(complex: $complexInput) {
1209+
name
1210+
}
11791211
}
11801212

11811213
query TakesListOfBooleanBang($booleans: [Boolean!]) {
1182-
# ...
1214+
booleanList(booleanListArg: $booleans)
11831215
}
11841216
```
11851217

0 commit comments

Comments
 (0)