Skip to content

Commit c7c3ee1

Browse files
committed
PR feedback
1 parent ffb8cad commit c7c3ee1

File tree

2 files changed

+53
-46
lines changed

2 files changed

+53
-46
lines changed

spec/Section 3 -- Type System.md

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,13 +1947,13 @@ GraphQL implementations that support the type system definition language must
19471947
provide the `@deprecated` directive if representing deprecated portions of the
19481948
schema.
19491949

1950-
GraphQL services are not required to implement the `@defer` and `@stream`
1951-
directives. If either or both of these directives are implemented, they must be
1952-
implemented according to this specification. GraphQL services that do not
1953-
support these directives must not make them available via introspection. The
1954-
[Directives Are Defined](#sec-Directives-Are-Defined) validation rule will
1955-
prevent GraphQL Operations containing the `@defer` or `@stream` directive from
1956-
being executed by a GraphQL service that does not implement these directives.
1950+
GraphQL implementations may provide the `@defer` and/or `@stream` directives. If
1951+
either or both of these directives are provided, they must conform to the
1952+
requirements defined in this specification.
1953+
1954+
Note: The [Directives Are Defined](#sec-Directives-Are-Defined) validation rule
1955+
ensures that GraphQL Operations containing the `@defer` or `@stream` directives
1956+
cannot be executed by a GraphQL service that does not support them.
19571957

19581958
GraphQL implementations that support the type system definition language should
19591959
provide the `@specifiedBy` directive if representing custom scalar definitions.
@@ -2181,15 +2181,16 @@ directive @defer(
21812181
) on FRAGMENT_SPREAD | INLINE_FRAGMENT
21822182
```
21832183

2184-
The `@defer` directive may be provided for fragment spreads and inline fragments
2185-
to inform the executor to delay the execution of the current fragment to
2186-
indicate deprioritization of the current fragment. A query with `@defer`
2187-
directive will cause the request to potentially return multiple responses, where
2188-
deferred data is delivered in subsequent responses. `@include` and `@skip` take
2189-
precedence over `@defer`.
2184+
The `@defer` directive may be provided on a fragment spread or inline fragment
2185+
to indicate that execution of the related selection set should be deferred. When
2186+
a request includes the `@defer` directive, the response may consist of multiple
2187+
payloads: the initial payload containing all non-deferred data, while subsequent
2188+
payloads include deferred data.
2189+
2190+
The `@include` and `@skip` directives take precedence over `@defer`.
21902191

21912192
```graphql example
2192-
query myQuery($shouldDefer: Boolean) {
2193+
query myQuery($shouldDefer: Boolean! = true) {
21932194
user {
21942195
name
21952196
...someFragment @defer(label: "someLabel", if: $shouldDefer)
@@ -2208,12 +2209,12 @@ fragment someFragment on User {
22082209
- `if: Boolean! = true` - When `true`, fragment _should_ be deferred (see
22092210
related note below). When `false`, fragment will not be deferred and data will
22102211
be included in the initial response. Defaults to `true` when omitted.
2211-
- `label: String` - May be used by GraphQL clients to identify the data from
2212-
responses and associate it with the corresponding defer directive. If
2213-
provided, the GraphQL service must add it to the corresponding pending object
2214-
in the response. `label` must be unique label across all `@defer` and
2215-
`@stream` directives in a document. `label` must not be provided as a
2216-
variable.
2212+
- `label: String` - An optional string literal (variables are disallowed) used
2213+
by GraphQL clients to identify data from responses and associate it with the
2214+
corresponding defer directive. If provided, the GraphQL service must include
2215+
this label in the corresponding pending object within the response. The
2216+
`label` argument must be unique across all `@defer` and `@stream` directives
2217+
in the document.
22172218

22182219
### @stream
22192220

@@ -2225,19 +2226,25 @@ directive @stream(
22252226
) on FIELD
22262227
```
22272228

2228-
The `@stream` directive may be provided for a field of `List` type so that the
2229-
backend can leverage technology such as asynchronous iterators to provide a
2230-
partial list in the initial response, and additional list items in subsequent
2231-
responses. `@include` and `@skip` take precedence over `@stream`. The
2232-
[Stream Directives Are Used On List Fields](#sec-Stream-Directives-Are-Used-On-List-Fields)
2233-
validation rule is used to prevent the `@stream` directive from being applied to
2234-
a field that is not a `List` type.
2229+
The `@stream` directive may be provided for a field whose type incorporates a
2230+
`List` type modifier; the directive enables the backend to leverage technology
2231+
such as asynchronous iterators to provide a partial list in the initial payload,
2232+
and additional list items in subsequent payloads.
2233+
2234+
The `@include` and `@skip` directives take precedence over `@stream`.
2235+
2236+
Note: The [Directives Are Defined](#sec-Directives-Are-Defined) validation rule
2237+
ensures that GraphQL Operations containing the `@stream` directive cannot be
2238+
executed by a GraphQL service that does not support this directive.
22352239

22362240
```graphql example
2237-
query myQuery($shouldStream: Boolean) {
2241+
query myQuery($shouldStream: Boolean! = true) {
22382242
user {
22392243
friends(first: 10) {
2240-
nodes @stream(label: "friendsStream", initialCount: 5, if: $shouldStream)
2244+
nodes
2245+
@stream(label: "friendsStream", initialCount: 5, if: $shouldStream) {
2246+
name
2247+
}
22412248
}
22422249
}
22432250
}
@@ -2248,12 +2255,12 @@ query myQuery($shouldStream: Boolean) {
22482255
- `if: Boolean! = true` - When `true`, field _should_ be streamed (see related
22492256
note below). When `false`, the field will not be streamed and all list items
22502257
will be included in the initial response. Defaults to `true` when omitted.
2251-
- `label: String` - May be used by GraphQL clients to identify the data from
2252-
responses and associate it with the corresponding stream directive. If
2253-
provided, the GraphQL service must add it to the corresponding pending object
2254-
in the response. `label` must be unique label across all `@defer` and
2255-
`@stream` directives in a document. `label` must not be provided as a
2256-
variable.
2258+
- `label: String` - An optional string literal (variables are disallowed) used
2259+
by GraphQL clients to identify data from responses and associate it with the
2260+
corresponding stream directive. If provided, the GraphQL service must include
2261+
this label in the corresponding pending object within the response. The
2262+
`label` argument must be unique across all `@defer` and `@stream` directives
2263+
in the document.
22572264
- `initialCount: Int` - The number of list items the service should return as
22582265
part of the initial response. If omitted, defaults to `0`. A field error will
22592266
be raised if the value of this argument is less than `0`.

spec/Section 7 -- Response.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ the case that any _field error_ was raised on a field and was replaced with
1111
## Response Format
1212

1313
A response to a GraphQL request must be a map or a stream of incrementally
14-
delivered results. The response will be a stream of incrementally delivered
15-
results when the GraphQL service has deferred or streamed data as a result of
14+
delivered payloads. The response will be a stream of incrementally delivered
15+
payloads when the GraphQL service has deferred or streamed data as a result of
1616
the `@defer` or `@stream` directives. When the response of the GraphQL operation
17-
contains incrementally delivered results, the first value will be an initial
17+
contains incrementally delivered payloads, the first value will be an initial
1818
payload, followed by one or more subsequent payloads.
1919

2020
If the request raised any errors, the response map must contain an entry with
@@ -28,14 +28,14 @@ request failed before execution, due to a syntax error, missing information, or
2828
validation error, this entry must not be present.
2929

3030
When the response of the GraphQL operation contains incrementally delivered
31-
results, both the initial payload and all subsequent payloads must contain an
31+
payloads, both the initial payload and all subsequent payloads must contain an
3232
entry with key `hasNext`. The value of this entry must be {true} for all but the
3333
last response in the stream. The value of this entry must be {false} for the
3434
last response of the stream. This entry must not be present for GraphQL
3535
operations that return a single response map.
3636

3737
When the response of the GraphQL operation contains incrementally delivered
38-
results, both the initial payload and any subsequent payloads may contain
38+
payloads, both the initial payload and any subsequent payloads may contain
3939
entries with the keys `pending`, `incremental`, and/or `completed`. The value of
4040
these entries are described in the "Pending", "Incremental", and "Completed"
4141
sections below.
@@ -71,7 +71,7 @@ If an error was raised during the execution that prevented a valid response, the
7171
`data` entry in the response should be `null`.
7272

7373
When the response of the GraphQL operation contains incrementally delivered
74-
results, `data` may only be present in the initial payload. `data` must not be
74+
payloads, `data` may only be present in the initial payload. `data` must not be
7575
present in any subsequent payloads.
7676

7777
### Errors
@@ -185,9 +185,9 @@ The response might look like:
185185
```
186186

187187
If the field which experienced an error was declared as `Non-Null`, the `null`
188-
result will bubble up to the next nullable field. In that case, the `path` for
189-
the error should include the full path to the result field where the error was
190-
raised, even if that field is not present in the response.
188+
result will propagate to the next nullable parent field. In that case, the
189+
`path` for the error should include the full path to the result field where the
190+
error was raised, even if that field is not present in the response.
191191

192192
For example, if the `name` field from above had declared a `Non-Null` return
193193
type in the schema, the result would look different but the error reported would
@@ -280,7 +280,7 @@ field which experienced the error.
280280
### Pending
281281

282282
The `pending` entry in the response is a non-empty list of Pending Results. If
283-
the response of the GraphQL operation contains incrementally delivered results,
283+
the response of the GraphQL operation contains incrementally delivered payloads,
284284
this field may appear on both the initial and subsequent payloads. If present,
285285
the `pending` entry must contain at least one Pending Result.
286286

@@ -321,7 +321,7 @@ payload, or one of the Incremental Results in a prior payload.
321321

322322
The `incremental` entry in the response is a non-empty list of Incremental
323323
Results. If the response of the GraphQL operation contains incrementally
324-
delivered results, this field may appear on both the initial and subsequent
324+
delivered payloads, this field may appear on both the initial and subsequent
325325
values. If present, the `incremental` entry must contain at least one
326326
Incremental Result.
327327

0 commit comments

Comments
 (0)