@@ -1556,6 +1556,55 @@ mutation {
15561556}
15571557```
15581558
1559+ ### Defer And Stream Directives Are Used On Valid Operations
1560+
1561+ ** Formal Specification **
1562+
1563+ - Let {subscriptionFragments} be the empty set.
1564+ - For each {operation} in a document:
1565+ - If {operation} is a subscription operation:
1566+ - Let {fragments} be every fragment referenced by that {operation}
1567+ transitively.
1568+ - For each {fragment} in {fragments}:
1569+ - Let {fragmentName} be the name of {fragment}.
1570+ - Add {fragmentName} to {subscriptionFragments}.
1571+ - For every {directive} in a document:
1572+ - If {directiveName} is not "defer" or "stream":
1573+ - Continue to the next {directive}.
1574+ - Let {ancestor} be the ancestor operation or fragment definition of
1575+ {directive}.
1576+ - If {ancestor} is a fragment definition:
1577+ - If the fragment name of {ancestor} is not present in
1578+ {subscriptionFragments}:
1579+ - Continue to the next {directive}.
1580+ - If {ancestor} is not a subscription operation:
1581+ - Continue to the next {directive}.
1582+ - Let {if} be the argument named "if" on {directive}.
1583+ - {if} must be defined.
1584+ - Let {argumentValue} be the value passed to {if}.
1585+ - {argumentValue} must be a variable, or the boolean value "false".
1586+
1587+ ** Explanatory Text**
1588+
1589+ The defer and stream directives can not be used to defer or stream data in
1590+ subscription operations. If these directives appear in a subscription operation
1591+ they must be disabled using the "if" argument. This rule will not permit any
1592+ defer or stream directives on a subscription operation that cannot be disabled
1593+ using the "if" argument.
1594+
1595+ For example, the following document will not pass validation because ` @defer `
1596+ has been used in a subscription operation with no "if" argument defined:
1597+
1598+ ``` raw graphql counter-example
1599+ subscription sub {
1600+ newMessage {
1601+ ... @defer {
1602+ body
1603+ }
1604+ }
1605+ }
1606+ ```
1607+
15591608### Defer And Stream Directive Labels Are Unique
15601609
15611610** Formal Specification **
0 commit comments