Skip to content

Commit 7886787

Browse files
committed
Address Roman's comments
1 parent 82e088d commit 7886787

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

spec/Section 2 -- Language.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ FragmentArgumentDefinition : Description? Variable : Type DefaultValue?
12251225
Directives[Const]?
12261226

12271227
Fragments may define locally scoped arguments, which can be used in locations
1228-
that accept variables. This allows fragments to be re-used while enabling the
1228+
that accept variables. This allows fragments to be reused while enabling the
12291229
caller to specify the fragment's behavior.
12301230

12311231
For example, the profile picture may need to be a different size depending on
@@ -1248,7 +1248,7 @@ fragment dynamicProfilePic($size: Int! = 50) on User {
12481248
}
12491249
```
12501250

1251-
In this case, the `user` will have a larger `profilePic` than those found in the
1251+
In this case the `user` will have a larger `profilePic` than those found in the
12521252
list of `friends`.
12531253

12541254
A fragment argument is scoped to the fragment that defines it. Fragment
@@ -1277,7 +1277,7 @@ The profilePic for `user` will be determined by the variables set by the
12771277
operation, while `secondUser` will always have a profilePic of size 10. In this
12781278
case, the fragment `variableProfilePic` uses the operation defined variable,
12791279
while `dynamicProfilePic` uses the value passed in via the fragment spread's
1280-
argument `size:`.
1280+
argument `size`.
12811281

12821282
## Type References
12831283

spec/Section 5 -- Validation.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,14 @@ fragment directFieldSelectionOnUnion on CatOrDog {
418418

419419
FieldsInSetCanMerge(set):
420420

421+
- Let {visitedSelections} be the selections in {set} including visiting
422+
fragments and inline fragments an applying any supplied fragment arguments.
423+
- Let {spreadsForName} be the set of fragment spreads with a given name in
424+
{visitedSelections}.
425+
- Given each pair of members {spreadA} and {spreadB} in {spreadsForName}:
426+
- {spreadA} and {spreadB} must have identical sets of arguments.
421427
- Let {fieldsForName} be the set of selections with a given response name in
422-
{set} including visiting fragments and inline fragments.
428+
{visitedSelections}.
423429
- Given each pair of members {fieldA} and {fieldB} in {fieldsForName}:
424430
- {SameResponseShape(fieldA, fieldB)} must be true.
425431
- If the parent types of {fieldA} and {fieldB} are equal or if either is not
@@ -605,14 +611,14 @@ fragment conflictingFragmentArguments on Dog {
605611
}
606612
```
607613

608-
the response will have two conflicting versions of the `doesKnowCommand` that
609-
cannot merge.
614+
the response will have two conflicting versions of the `doesKnowCommand`
615+
fragment that cannot merge.
610616

611-
One strategy to resolving field conflicts caused by duplicated fragment spreads
612-
is to short-circuit when two fragment spreads with the same name are found to be
613-
merging with different argument values. In this case, validation could short
614-
circuit when `commandFragment(command: SIT)` is merged with
615-
`commandFragment(command: DOWN)`.
617+
If two fragment spreads with the same name supply different argument values,
618+
their fields will not be able to merge. In this case, validation fails because
619+
the fragment spread `...commandFragment(command: SIT)` and
620+
`...commandFragment(command: DOWN)` are part of the visited selections that will
621+
be merged.
616622

617623
### Leaf Field Selections
618624

@@ -729,7 +735,7 @@ fragment usesFragmentArg on Dog {
729735
}
730736
```
731737

732-
the following is invalid since `command:` is not defined on
738+
The following is invalid since `command` is not defined on
733739
`Dog.doesKnowCommand`.
734740

735741
```graphql counter-example
@@ -738,7 +744,7 @@ fragment invalidArgName on Dog {
738744
}
739745
```
740746

741-
and this is also invalid as `$dogCommand` is not defined on fragment
747+
and this is also invalid as the argument `dogCommand` is not defined on fragment
742748
`withFragmentArg`.
743749

744750
```graphql counter-example
@@ -1892,7 +1898,7 @@ fragment isHouseTrainedWithoutVariableFragment on Dog {
18921898
```
18931899

18941900
Fragment arguments can shadow operation variables: fragments that use an
1895-
argument are not using the operation defined variable of the same name.
1901+
argument are not using the operation-defined variable of the same name.
18961902

18971903
Likewise, it would be invalid if the variable was shadowed by a fragment
18981904
argument:
@@ -1911,7 +1917,7 @@ fragment shadowedVariableFragment($atOtherHomes: Boolean) on Dog {
19111917

19121918
because
19131919
{$atOtherHomes} is only referenced in a fragment that defines it as a
1914-
locally scoped argument, the operation defined {$atOtherHomes}
1920+
locally scoped argument, the operation-defined {$atOtherHomes}
19151921
variable is never used.
19161922

19171923
All operations in a document must use all of their variables.
@@ -1951,11 +1957,10 @@ variable.
19511957
**Explanatory Text**
19521958

19531959
All arguments defined by a fragment must be used in that same fragment. Because
1954-
fragment arguments are scoped to the fragment they're defined on, if the
1955-
fragment does not contain a variable with the same name as the argument, then
1956-
the argument is superfluous.
1960+
fragment arguments are scoped to the fragment they are defined on, if the
1961+
fragment does not use the argument, then the argument is superfluous.
19571962

1958-
For example the following is invalid:
1963+
For example, the following is invalid:
19591964

19601965
```graphql counter-example
19611966
query queryWithFragmentArgUnused($atOtherHomes: Boolean) {

0 commit comments

Comments
 (0)