Skip to content

Commit

Permalink
validation suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Sep 4, 2024
1 parent 984cd0d commit 25512c5
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions spec/Section 5 -- Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ This is because {houseTrainedQueryTwoNotDefined} does not define a variable
${atOtherHomes} but that variable is used by {isHouseTrainedFragment} which is
included in that operation.

### All Operation Variables Used
### All Variables Used

**Formal Specification**

Expand All @@ -1882,6 +1882,11 @@ included in that operation.
- Each {variable} in {variables} must be used at least once in either the
operation scope itself or any fragment transitively referenced by that
operation, excluding fragments that define the same name as an argument.
- For every {fragment} in the document:
- Let {variables} be the variables defined by that {fragment}.
- Each {variable} in {variables} must be used at least once transitively
within the fragment's selection set excluding traversal of named fragment
spreads.

**Explanatory Text**

Expand Down Expand Up @@ -1982,24 +1987,8 @@ fragment isHouseTrainedFragment on Dog {
This document is not valid because {queryWithExtraVar} defines an extraneous
variable.

### All Fragment Variables Used

**Formal Specification**

- For every {fragment} in the document:
- Let {variables} be the variables defined by that {fragment}.
- Each {variable} in {variables} must be used at least once transitively
within the fragment's selection set excluding traversal of named fragment
spreads.

**Explanatory Text**

All variables defined by a fragment must be used in that same fragment. Because
fragment-defined variables are scoped to the fragment they are defined on, if
the fragment does not use the variable, then the variable definition is
superfluous.

For example, the following is invalid:
Fragment variables must also be used within their definitions. For example, the
following is invalid:

```graphql counter-example
query queryWithFragmentArgUnused($atOtherHomes: Boolean) {
Expand Down

0 comments on commit 25512c5

Please sign in to comment.