Skip to content

Commit 14c93e8

Browse files
committed
Expand on validation rule for field selection merging
This adds additional spec text to make it clear that field selection merging is a recursive operation.
1 parent 04f9b72 commit 14c93e8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

spec/Section 5 -- Validation.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ fragment directFieldSelectionOnUnion on CatOrDog {
279279

280280
** Formal Specification **
281281

282-
* Let {set} be any selection set defined in the GraphQL document
282+
* Let {set} be any selection set defined in the GraphQL document.
283+
* {FieldsInSetCanMerge(set)} must be true.
284+
285+
FieldsInSetCanMerge(set) :
283286
* Let {fieldsForName} be the set of selections with a given response name in
284287
{set} including visiting fragments and inline fragments.
285288
* Given each pair of members {fieldA} and {fieldB} in {fieldsForName}:
@@ -288,13 +291,16 @@ fragment directFieldSelectionOnUnion on CatOrDog {
288291
* {fieldA} and {fieldB} must have identical field names.
289292
* {fieldA} and {fieldB} must have identical return type.
290293
* {fieldA} and {fieldB} must have identical sets of arguments.
294+
* Let {mergedSet} be the result of adding the selection set of {fieldA}
295+
and the selection set of {fieldB}.
296+
* {FieldsInSetCanMerge(mergedSet)} must be true.
291297

292298
** Explanatory Text **
293299

294300
If multiple fields selections with the same response names are encountered
295-
during execution, the result should be unambiguous. Therefore any two field
296-
selections which might both be encountered for the same object are only valid if
297-
they are equivalent.
301+
during execution, the field and arguments to execute and the resulting value
302+
should be unambiguous. Therefore any two field selections which might both be
303+
encountered for the same object are only valid if they are equivalent.
298304

299305
For simple hand-written GraphQL, this rule is obviously a clear developer error,
300306
however nested fragments can make this difficult to detect manually.

0 commit comments

Comments
 (0)