Skip to content

Commit 48243bf

Browse files
committed
Merge branch 'master' of github.com:facebook/graphql
2 parents 9a7fb33 + ba049f9 commit 48243bf

File tree

2 files changed

+59
-29
lines changed

2 files changed

+59
-29
lines changed

spec/Section 5 -- Validation.md

Lines changed: 58 additions & 28 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
@@ -870,7 +887,7 @@ fragment ownerFragment on Dog {
870887

871888
** Formal Specification **
872889

873-
* For each {spread} (named or inline) in defined in the document.
890+
* For each {spread} (named or inline) defined in the document.
874891
* Let {fragment} be the target of {spread}
875892
* Let {fragmentType} be the type condition of {fragment}
876893
* Let {parentType} be the type of the selection set containing {spread}
@@ -893,7 +910,7 @@ the parent type.
893910

894911
##### Object Spreads In Object Scope
895912

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
897914
fragment spread is one that applies to the same type that
898915
is in scope.
899916

@@ -946,7 +963,7 @@ fragment catOrDogNameFragment on CatOrDog {
946963
}
947964

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

@@ -1083,11 +1100,9 @@ For example the following query will not pass validation.
10831100
GraphQL servers define what directives they support. For each
10841101
usage of a directive, the directive must be available on that server.
10851102

1086-
## Operations
1087-
1088-
### Variables
1103+
## Variables
10891104

1090-
#### Variable Default Values Are Correctly Typed
1105+
### Variable Default Values Are Correctly Typed
10911106

10921107
** Formal Specification **
10931108

@@ -1100,8 +1115,8 @@ usage of a directive, the directive must be available on that server.
11001115

11011116
** Explanatory Text **
11021117

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.
11051120

11061121
For example the following query will pass validation.
11071122

@@ -1150,7 +1165,7 @@ query intToFloatQuery($floatVar: Float = 1) {
11501165
}
11511166
```
11521167

1153-
#### Variables Are Input Types
1168+
### Variables Are Input Types
11541169

11551170
** Formal Specification **
11561171

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

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+
11701196
The following queries are valid:
11711197

11721198
```graphql
11731199
query takesBoolean($atOtherHomes: Boolean) {
1174-
# ...
1200+
dog {
1201+
isHousetrained(atOtherHomes: $atOtherHomes)
1202+
}
11751203
}
11761204

11771205
query takesComplexInput($complexInput: ComplexInput) {
1178-
# ...
1206+
findDog(complex: $complexInput) {
1207+
name
1208+
}
11791209
}
11801210

11811211
query TakesListOfBooleanBang($booleans: [Boolean!]) {
1182-
# ...
1212+
booleanList(booleanListArg: $booleans)
11831213
}
11841214
```
11851215

@@ -1203,7 +1233,7 @@ query takesCatOrDog($catOrDog: CatOrDog) {
12031233
}
12041234
```
12051235

1206-
#### All Variable Uses Defined
1236+
### All Variable Uses Defined
12071237

12081238
** Formal Specification **
12091239

@@ -1345,7 +1375,7 @@ This is because {housetrainedQueryTwoNotDefined} does not define
13451375
a variable ${atOtherHomes} but that variable is used by {isHousetrainedFragment}
13461376
which is included in that operation.
13471377

1348-
#### All Variables Used
1378+
### All Variables Used
13491379

13501380
** Formal Specification **
13511381

@@ -1427,7 +1457,7 @@ fragment isHousetrainedFragment on Dog {
14271457
This document is not valid because {queryWithExtraVar} defines
14281458
an extraneous variable.
14291459

1430-
#### All Variable Usages are Allowed
1460+
### All Variable Usages are Allowed
14311461

14321462
** Formal Specification **
14331463

spec/Section 6 -- Execution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ will be an entry in this map for every item in the grouped field set.
118118
### Field entries
119119

120120
Each item in the grouped field set can potentially create an entry in the
121-
result map. That entry in the result map is the result is the result of calling
121+
result map. That entry in the result map is the result of calling
122122
`GetFieldEntry` on the corresponding item in the grouped field set.
123123
`GetFieldEntry` can return `null`, which indicates that there should be no
124124
entry in the result map for this item. Note that this is distinct from

0 commit comments

Comments
 (0)