Skip to content

Commit d8c28d1

Browse files
committed
add validation “Defer And Stream Directive Labels Are Unique”
1 parent 75f2258 commit d8c28d1

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

spec/Section 5 -- Validation.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,71 @@ mutation {
15561556
}
15571557
```
15581558

1559+
### Defer And Stream Directive Labels Are Unique
1560+
1561+
** Formal Specification **
1562+
1563+
- For every {directive} in a document.
1564+
- Let {directiveName} be the name of {directive}.
1565+
- If {directiveName} is "defer" or "stream":
1566+
- For every {argument} in {directive}:
1567+
- Let {argumentName} be the name of {argument}.
1568+
- Let {argumentValue} be the value passed to {argument}.
1569+
- If {argumentName} is "label":
1570+
- {argumentValue} must not be a variable.
1571+
- Let {labels} be all label values passed to defer or stream directive label
1572+
arguments.
1573+
- {labels} must be a set of one.
1574+
1575+
**Explanatory Text**
1576+
1577+
The `@defer` and `@stream` directives each accept an argument "label". This
1578+
label may be used by GraphQL clients to uniquely identify response payloads. If
1579+
a label is passed, it must not be a variable and it must be unique within all
1580+
other `@defer` and `@stream` directives in the document.
1581+
1582+
For example the following document is valid:
1583+
1584+
```graphql example
1585+
{
1586+
dog {
1587+
...fragmentOne
1588+
...fragmentTwo @defer(label: "dogDefer")
1589+
}
1590+
pets @stream(label: "petStream") {
1591+
name
1592+
}
1593+
}
1594+
1595+
fragment fragmentOne on Dog {
1596+
name
1597+
}
1598+
1599+
fragment fragmentTwo on Dog {
1600+
owner {
1601+
name
1602+
}
1603+
}
1604+
```
1605+
1606+
For example, the following document will not pass validation because the same
1607+
label is used in different `@defer` and `@stream` directives.:
1608+
1609+
```raw graphql counter-example
1610+
{
1611+
dog {
1612+
...fragmentOne @defer(label: "MyLabel")
1613+
}
1614+
pets @stream(label: "MyLabel") {
1615+
name
1616+
}
1617+
}
1618+
1619+
fragment fragmentOne on Dog {
1620+
name
1621+
}
1622+
```
1623+
15591624
### Stream Directives Are Used On List Fields
15601625

15611626
**Formal Specification**

0 commit comments

Comments
 (0)