Skip to content

Commit db40f80

Browse files
committed
add explicit example for fragment variables that resolve to operation variables
1 parent da7743e commit db40f80

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

spec/Section 5 -- Validation.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,29 @@ validation fails because the fragment spread `...commandFragment(command: SIT)`
609609
and `...commandFragment(command: DOWN)` are part of the visited selections that
610610
will be merged.
611611

612-
If both of these spreads had used the same variable for the argument value, it
613-
would be allowed as we can be sure that we'd resolve identical fields.
612+
If both of these spreads had used the same value for the argument value, it
613+
would be allowed as we can be sure that we would resolve identical fields.
614+
Spreads that use different variables that would always resolve to the same value
615+
are also valid. For example, the following is valid:
616+
617+
```graphql example
618+
fragment commandFragment($command: DogCommand!) on Dog {
619+
doesKnowCommand(dogCommand: $command)
620+
}
621+
622+
fragment noConflictWhenPassedOperationCommand(
623+
$fragmentCommand: DogCommand!
624+
) on Dog {
625+
...commandFragment(command: $operationCommand)
626+
...commandFragment(command: $fragmentCommand)
627+
}
628+
629+
query($operationCommand: DogCommand!) {
630+
pet {
631+
...noConflictWhenPassedOperationCommand(fragmentCommand: $operationCommand)
632+
}
633+
}
634+
```
614635

615636
### Leaf Field Selections
616637

0 commit comments

Comments
 (0)