Skip to content

Commit 42c7aea

Browse files
authored
Fix typos in the GraphQL Defer and Stream Directives RFC (#807)
1 parent d248f55 commit 42c7aea

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

rfcs/DeferStream.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Given a query where some fields are expensive and non-essential, non-essential f
2525
## Prefetching
2626
This technique involves optimistically fetching data based on a prediction that a user will execute an action. Prefetching can be one of the most effective ways of reducing latency. However, a significant tradeoff with prefetching that a lot of applications cannot afford is **increased server cost due to incorrect predictions.** With an unsophisticated prefetch algorithm, applications can easily overfetch by a factor of 10 fold.
2727

28-
# Proposal: Incrementally deliver data with @defer and @stream
28+
# Proposal: Incrementally deliver data with `@defer` and `@stream`
2929

30-
This proposal would introduce @stream and @defer directives which clients could use to communicate the relative priority of requested data to GraphQL implementations. Furthermore this proposal would enable GraphQL APIs to split requested data across multiple response payloads in order of priority. The goal of this proposal is to enable applications to reduce latency without increasing server cost or resource contention.
30+
This proposal would introduce `@stream` and `@defer` directives which clients could use to communicate the relative priority of requested data to GraphQL implementations. Furthermore this proposal would enable GraphQL APIs to split requested data across multiple response payloads in order of priority. The goal of this proposal is to enable applications to reduce latency without increasing server cost or resource contention.
3131

3232
While both incremental delivery and GraphQL subscriptions send multiple payloads over time, **incremental delivery is _not_ intended to enable applications to respond to real-time changes.** Consequently streams opened for incremental delivery are expected to be short-lived. **Implementations are not required to reflect interleaving mutations which occur during incremental delivery.** Assuming there are no interleaving mutations, combining together the various payloads in an incrementally delivered response should produce the same output as if that response was not delivered incrementally.
3333

@@ -36,7 +36,7 @@ Facebook has been using Incremental Delivery at scale since 2017, including on m
3636
GraphQL servers will not be required to implement `@defer` and/or `@stream`. If they are implemented, they will be required to follow the proposed specification. Servers that do not implement `@defer` and/or `@stream` should not expose these directives in their schema. Queries containing these directives that are sent to an unsupported server should fail validation.
3737

3838
## `@defer`
39-
The @defer directive may be specified on a fragment spread to imply de-prioritization, that causes the fragment to be omitted in the initial response, and delivered as a subsequent response afterward. A query with @defer directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred delivered in a subsequent response. `@include` and `@skip` take presedence over `@defer`.
39+
The `@defer` directive may be specified on a fragment spread to imply de-prioritization, that causes the fragment to be omitted in the initial response, and delivered as a subsequent response afterward. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`.
4040

4141
### `@defer` arguments
4242
* `if: Boolean`
@@ -48,9 +48,9 @@ The @defer directive may be specified on a fragment spread to imply de-prioritiz
4848

4949
## `@stream`
5050

51-
The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take presedence over `@stream`.
51+
The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`.
5252

53-
### `@stream `arguments
53+
### `@stream` arguments
5454
* `if: Boolean`
5555
* When `true` field may be streamed, if omitted defaults to `true`.
5656
* `label: String`
@@ -64,23 +64,23 @@ The `@stream` directive may be provided for a field of `List` type so that the b
6464

6565
When an operation contains `@defer` or `@stream` directives, the GraphQL execution will return multiple payloads. The first payload is the same shape as a standard GraphQL response. Any fields that were only requested on a fragment that is deferred will not be present in this payload. Any list fields that are streamed will only contain the initial list items.
6666

67-
Each subsequent payload will be an object with the following properties
68-
* `label`: The string that was passed to the label argument of the `@defer` or `@stream` directive that corresponds to this results.
67+
Each subsequent payload will be an object with the following properties:
68+
* `label`: The string that was passed to the label argument of the `@defer` or `@stream` directive that corresponds to this result.
6969
* `data`: The data that is being delivered incrementally.
7070
* `path`: a list of keys (with plural indexes) from the root of the response to the insertion point that informs the client how to patch a subsequent delta payload into the original payload.
71-
* `hasNext`: A boolean that is present and `true` when there are more payloads that will be sent for this operation. The last payload in a multi payload response should return `hasNext: false`. `hasNext` is not required for single-payload responses to preserve backwards compatibility.
71+
* `hasNext`: A boolean that is present and `true` when there are more payloads that will be sent for this operation. The last payload in a multi-payload response should return `hasNext: false`. `hasNext` is not required for single-payload responses to preserve backwards compatibility.
7272
* `errors`: An array that will be present and contain any field errors that are produced while executing the deferred or streamed selection set.
73-
* `extensions`: For implementors to extend the protocol
73+
* `extensions`: For implementors to extend the protocol.
7474

7575
Note: The `label` field is not a unique identifier for payloads. There may be multiple payloads with the same label for either payloads for `@stream`, or payloads from a `@defer` fragment under a list field. The combination of `label` and `path` will be unique among all payloads.
7676

7777
## Server requirements for `@defer` and `@stream`
7878

79-
The ability to defer/stream parts of a response can have a potentially significant impact on application performance. Developers generally need clear, predictable control over their application's performance. It is highly recommended that the GraphQL server honor the @defer and @stream directives on each execution. However, the specification will allow advanced use-cases where the server can determine that it is more performant to not defer/stream. Therefore, GraphQL clients should be able to process a response that ignores the defer/stream directives.
79+
The ability to defer/stream parts of a response can have a potentially significant impact on application performance. Developers generally need clear, predictable control over their application's performance. It is highly recommended that the GraphQL server honor the `@defer` and `@stream` directives on each execution. However, the specification will allow advanced use-cases where the server can determine that it is more performant to not defer/stream. Therefore, GraphQL clients should be able to process a response that ignores the defer/stream directives.
8080

8181
This also applies to the `initialCount` argument on the `@stream` directive. Clients should be able to process a streamed response that contains a different number of initial list items than what was specified in the `initialCount` argument.
8282

83-
## Example Query with @defer and @stream
83+
## Example Query with `@defer` and `@stream`
8484

8585
```
8686
{
@@ -133,30 +133,30 @@ fragment GroupAdminFragment {
133133
```
134134

135135
## Benefits of incremental delivery
136-
* Make GraphQL a great choice for applications which demand responsiveness
136+
* Make GraphQL a great choice for applications which demand responsiveness.
137137
* Enable interoperability between different GraphQL clients and servers without restricting implementation.
138138
* Enable a strong tooling ecosystem (including GraphiQL).
139-
* Provide concrete guidance to implementers
140-
* Provide guidance to developers evaluating whether to adopt incremental delivery
139+
* Provide concrete guidance to implementers.
140+
* Provide guidance to developers evaluating whether to adopt incremental delivery.
141141

142142
## Use case guidance:
143-
The goal of incremental delivery is to prioritize the delivery of essential data. Even though incremental delivery delivers data over time, the response describes the data at a particular point in time. Therefore, it is not necessary to reflect real time changes to the data model in incremental delivery. Implementers of @defer and @stream are not obligated to address interleaving mutations during the execution of @defer and @stream.
143+
The goal of incremental delivery is to prioritize the delivery of essential data. Even though incremental delivery delivers data over time, the response describes the data at a particular point in time. Therefore, it is not necessary to reflect real time changes to the data model in incremental delivery. Implementers of `@defer` and `@stream` are not obligated to address interleaving mutations during the execution of `@defer` and `@stream`.
144144

145-
GraphQL Subscription is an event-oriented approach to capture real time data changes. It intends to describe interesting events that happen over a period of time and delivers updated value that “invalidate” previous values.
145+
GraphQL Subscription is an event-oriented approach to capture real time data changes. It intends to describe interesting events that happen over a period of time and delivers updated values that “invalidate” previous values.
146146

147-
## Implementation details of @stream and @defer
147+
## Implementation details of `@stream` and `@defer`
148148

149149
For GraphQL communications built on top of HTTP, a natural and compatible technology to leverage is HTTP chunked encoding to implement a stream of responses for incremental delivery.
150150

151151
## Caveats
152152

153153
### Type Generation
154-
Supporting @defer can add complexity to type-generating clients. Separate types will need to be generated for the different deferred fragments. These clients will need to use the `label` field to determine which fragments have been fulfilled to ensure the application is using the correct types.
154+
Supporting `@defer` can add complexity to type-generating clients. Separate types will need to be generated for the different deferred fragments. These clients will need to use the `label` field to determine which fragments have been fulfilled to ensure the application is using the correct types.
155155

156156
### Object Consistency
157157
The GraphQL spec does not currently support object identification or consistency. It is currently possible for the same object to be returned in multiple places in a query. If that object changes while the resolvers are running, the query could return inconsistent results. `@defer`/`@stream` does not increase the likelihood of this, as the server still attempts to resolve everything as fast as it can. The only difference is some results can be returned to the client sooner. This proposal does not attempt to address this issue.
158158

159-
### Can @defer/@stream increase risk of a denial of service attack?
159+
### Can `@defer`/`@stream` increase risk of a denial of service attack?
160160
This is currently a risk in GraphQL servers that do not implement any kind of query limiting as arbitrarily complex queries can be sent. Adding `@defer` may add some overhead as the server will now send parts of the query earlier than it would have without `@defer`, but it does not allow for any additional resolving that was not previously possible.
161161

162162

0 commit comments

Comments
 (0)