Skip to content

Commit 7ec40df

Browse files
committed
Consistency
1 parent 6536944 commit 7ec40df

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

spec/Section 5 -- Validation.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,9 @@ validation rules apply in each case.
874874
**Explanatory Text**
875875

876876
Every argument provided to a field or directive must be defined in the set of
877-
possible arguments of that field or directive.
877+
possible arguments of that field or directive. Every argument provided to a
878+
named fragment spread must be defined in the set of possible variables of that
879+
named fragment.
878880

879881
For example the following are valid:
880882

@@ -886,13 +888,7 @@ fragment argOnRequiredArg on Dog {
886888
fragment argOnOptional on Dog {
887889
isHouseTrained(atOtherHomes: true) @include(if: true)
888890
}
889-
```
890-
891-
The above is also applicable to fragment definitions and fragment spreads, each
892-
variable must be defined by the fragment definition before it can be inserted as
893-
an argument by the fragment spread.
894891

895-
```graphql example
896892
fragment withFragmentArg($command: DogCommand) on Dog {
897893
doesKnowCommand(dogCommand: $command)
898894
}
@@ -902,17 +898,25 @@ fragment usesFragmentArg on Dog {
902898
}
903899
```
904900

905-
The following is invalid since `command` is not defined on
906-
`Dog.doesKnowCommand`.
901+
The following is invalid since the argument `command` is not defined on
902+
`Dog.doesKnowCommand`:
907903

908904
```graphql counter-example
909905
fragment invalidArgName on Dog {
910906
doesKnowCommand(command: CLEAN_UP_HOUSE)
911907
}
912908
```
913909

914-
and this is also invalid as the argument `dogCommand` is not defined on fragment
915-
`withFragmentArg`.
910+
This is also invalid as `unless` is not defined on `@include`:
911+
912+
```graphql counter-example
913+
fragment invalidArgName on Dog {
914+
isHouseTrained(atOtherHomes: true) @include(unless: false)
915+
}
916+
```
917+
918+
Since the argument `dogCommand` is not defined on fragment `withFragmentArg`,
919+
this is also invalid:
916920

917921
```graphql counter-example
918922
fragment invalidFragmentArgName on Dog {
@@ -924,14 +928,6 @@ fragment withFragmentArg($command: DogCommand) on Dog {
924928
}
925929
```
926930

927-
and this is also invalid as `unless` is not defined on `@include`.
928-
929-
```graphql counter-example
930-
fragment invalidArgName on Dog {
931-
isHouseTrained(atOtherHomes: true) @include(unless: false)
932-
}
933-
```
934-
935931
In order to explore more complicated argument examples, let's add the following
936932
to our type system:
937933

0 commit comments

Comments
 (0)