-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Spec edits for incremental delivery, Response Section and Examples Appendix #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robrichard
wants to merge
4
commits into
incremental-integration
Choose a base branch
from
incremental-integration-response
base: incremental-integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+436
−6
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| # E. Appendix: Examples | ||
|
|
||
| ## Incremental Delivery Examples | ||
|
|
||
| ### Example 1 - A query containing both defer and stream | ||
|
|
||
| ```graphql example | ||
| query { | ||
| person(id: "cGVvcGxlOjE=") { | ||
| ...HomeWorldFragment @defer(label: "homeWorldDefer") | ||
| name | ||
| films @stream(initialCount: 1, label: "filmsStream") { | ||
| title | ||
| } | ||
| } | ||
| } | ||
| fragment HomeWorldFragment on Person { | ||
| homeWorld { | ||
| name | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The _incremental stream_ might look like: | ||
|
|
||
| The _initial execution result_ does not contain any deferred or streamed results | ||
| in the {"data"} entry. The initial execution result contains a {"hasNext"} | ||
| entry, indicating that _execution update result_ will be delivered. There are | ||
| two _pending result_ indicating that results for both the `@defer` and `@stream` | ||
| in the query will be delivered in the execution update results. | ||
benjie marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```json example | ||
| { | ||
| "data": { | ||
| "person": { | ||
| "name": "Luke Skywalker", | ||
| "films": [{ "title": "A New Hope" }] | ||
| } | ||
| }, | ||
| "pending": [ | ||
| { "id": "0", "path": ["person"], "label": "homeWorldDefer" }, | ||
| { "id": "1", "path": ["person", "films"], "label": "filmsStream" } | ||
| ], | ||
| "hasNext": true | ||
| } | ||
| ``` | ||
|
|
||
| _Execution update result_ 1 contains the deferred data and the first streamed | ||
benjie marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| list item. There is one _completed result_, indicating that the deferred data | ||
| has been completely delivered. | ||
|
|
||
| ```json example | ||
| { | ||
| "incremental": [ | ||
| { | ||
| "id": "0", | ||
| "data": { "homeWorld": { "name": "Tatooine" } } | ||
| }, | ||
| { | ||
| "id": "1", | ||
| "items": [{ "title": "The Empire Strikes Back" }] | ||
| } | ||
| ], | ||
| "completed": [ | ||
| {"id": "0"} | ||
| ] | ||
| "hasNext": true | ||
| } | ||
| ``` | ||
|
|
||
| _Execution update result_ 2 contains the final stream results. In this example, | ||
| the underlying iterator does not close synchronously so {"hasNext"} is set to | ||
| {true}. If this iterator did close synchronously, {"hasNext"} would be set to | ||
| {false} and this would be the final execution update result. | ||
|
|
||
| ```json example | ||
| { | ||
| "incremental": [ | ||
| { | ||
| "id": "1", | ||
| "items": [{ "title": "Return of the Jedi" }] | ||
| } | ||
| ], | ||
| "hasNext": true | ||
| } | ||
| ``` | ||
|
|
||
| _Execution update result_ 3 contains no incremental data. {"hasNext"} set to | ||
| {false} indicates the end of the _incremental stream_. This response is sent | ||
| when the underlying iterator of the `films` field closes. | ||
|
|
||
| ```json example | ||
| { | ||
| "hasNext": false | ||
| } | ||
| ``` | ||
|
|
||
| ### Example 2 - A query containing overlapping defers | ||
|
|
||
| ```graphql example | ||
| query { | ||
| person(id: "cGVvcGxlOjE=") { | ||
| ...HomeWorldFragment @defer(label: "homeWorldDefer") | ||
| ...NameAndHomeWorldFragment @defer(label: "nameAndWorld") | ||
| firstName | ||
| } | ||
| } | ||
| fragment HomeWorldFragment on Person { | ||
| homeWorld { | ||
| name | ||
| terrain | ||
| } | ||
| } | ||
|
|
||
| fragment NameAndHomeWorldFragment on Person { | ||
| firstName | ||
| lastName | ||
| homeWorld { | ||
| name | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The _incremental stream_ might look like: | ||
|
|
||
| The _initial execution result_ contains the results of the `firstName` field. | ||
| Even though it is also present in the `HomeWorldFragment`, it must be returned | ||
| in the initial response because it is also defined outside of any fragments with | ||
| the `@defer` directive. Additionally, there are two _pending result_ indicating | ||
| that results for both `@defer`s in the query will be delivered in the execution | ||
| update results. | ||
|
|
||
| ```json example | ||
| { | ||
| "data": { | ||
| "person": { | ||
| "firstName": "Luke" | ||
| } | ||
| }, | ||
| "pending": [ | ||
| { "id": "0", "path": ["person"], "label": "homeWorldDefer" }, | ||
| { "id": "1", "path": ["person"], "label": "nameAndWorld" } | ||
| ], | ||
| "hasNext": true | ||
| } | ||
| ``` | ||
|
|
||
| _Execution update result_ 1 contains the deferred data from `HomeWorldFragment`. | ||
| There is one Completed Result, indicating that `HomeWorldFragment` has been | ||
| completely delivered. Because the `homeWorld` field is present in two separate | ||
| `@defer`s, it is separated into its own _incremental result_. | ||
|
|
||
| The second _incremental result_ contains the data for the `terrain` field. This | ||
| _incremental result_ contains a {"subPath"} entry to indicate to clients that | ||
| the path of this result can be determined by concatenating the path from the | ||
| _pending result_ with id `"0"` and this {"subPath"} entry. | ||
|
|
||
| ```json example | ||
| { | ||
| "incremental": [ | ||
| { | ||
| "id": "0", | ||
| "data": { "homeWorld": { "name": "Tatooine" } } | ||
| }, | ||
| { | ||
| "id": "0", | ||
| "subPath": ["homeWorld"], | ||
| "data": { "terrain": "desert" } | ||
| } | ||
| ], | ||
| "completed": [{ "id": "0" }], | ||
| "hasNext": true | ||
| } | ||
| ``` | ||
|
|
||
| _Execution update result_ 2 contains the remaining data from the | ||
| `NameAndHomeWorldFragment`. `lastName` is the only remaining field that has not | ||
| been delivered in a previous response. | ||
|
|
||
| ```json example | ||
| { | ||
| "incremental": [ | ||
| { | ||
| "id": "1", | ||
| "data": { "lastName": "Skywalker" } | ||
| } | ||
| ], | ||
| "completed": [{ "id": "1" }], | ||
| "hasNext": false | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.