Spec edits for incremental delivery, Response Section and Examples Appendix#1203
Spec edits for incremental delivery, Response Section and Examples Appendix#1203robrichard wants to merge 14 commits intoincremental-integrationfrom
Conversation
2bb67fc to
30bc97f
Compare
|
is this stuck in limbo? Or is there something that I could help on? |
benjie
left a comment
There was a problem hiding this comment.
I don't know if it's just me, but I feel like the examples could use more narrative and explanation that this is just one way the query could turn out. Here's how I'd change the beginning of the first example:
c024bf1 to
9e42f6c
Compare
003ed2a to
87a05e3
Compare
Initial Execution Result > Initial Incremental Stream Result Execution Update Result > Incremental Stream Update Result
…tal stream update result_
6b7397a to
b9d8e8a
Compare
spec/Appendix E -- Examples.md
Outdated
| Depending on the behavior of the backend and the time at which the deferred and | ||
| streamed resources resolve, the stream may produce results in different orders. | ||
| In this example, our first _incremental stream update result_ contains the | ||
| deferred data and the first streamed list item. There is one _completed result_, |
There was a problem hiding this comment.
Maybe change "completed result" to "incremental completion result" to tie it in with the "incremental" naming? (Also to be more specific.)
| deferred data and the first streamed list item. There is one _completed result_, | |
| deferred data and the first streamed list item. There is one _incremental completion result_, |
There was a problem hiding this comment.
Updated now to incremental completion notice
| { | ||
| "id": "0", | ||
| "data": { "homeWorld": { "name": "Tatooine" } } | ||
| }, |
There was a problem hiding this comment.
I feel like the weirdness of this needs more calling out - name belongs to both id:0 and id:1, so we're kind of using id:0 as a shortcut (but id:1 would also work). We should make it clear to a client that it can't form HomeWorldFragment from solely the root data plus the id:0 stuff and NameAndHomeWorldFragment from solely the root data and the id:1 stuff - they must merge the trees before extracting the data.
There was a problem hiding this comment.
spec/Section 7 -- Response.md
Outdated
| The _initial incremental stream result_ must contain an entry with key {"data"}, | ||
| and may contain entries with keys {"errors"} and {"extensions"}. The value of | ||
| these entries are defined in the same way as an _execution result_ as described | ||
| in the "Data", "Errors", and "Extensions" sections below. | ||
|
|
||
| The _initial incremental stream result_ must contain an entry with the key | ||
| {"hasNext"}. The value of this entry must be {true} if there are any | ||
| _incremental stream update results_ in the _incremental stream_. The value of | ||
| this entry must be {false} if the initial incremental stream result is the last | ||
| response of the incremental stream. |
There was a problem hiding this comment.
Splitting this across two paragraphs is a little weird, I feel like the list of keys up front should be exhaustive.
| The _initial incremental stream result_ must contain an entry with key {"data"}, | |
| and may contain entries with keys {"errors"} and {"extensions"}. The value of | |
| these entries are defined in the same way as an _execution result_ as described | |
| in the "Data", "Errors", and "Extensions" sections below. | |
| The _initial incremental stream result_ must contain an entry with the key | |
| {"hasNext"}. The value of this entry must be {true} if there are any | |
| _incremental stream update results_ in the _incremental stream_. The value of | |
| this entry must be {false} if the initial incremental stream result is the last | |
| response of the incremental stream. | |
| The _initial incremental stream result_ must contain an entries with keys {"data"} and {"hasNext"}, and may contain entries with keys | |
| {"errors"}, {"pending"}, {"incremental"}, {"completed"}, and {"extensions"}. | |
| The value of {"data"}, {"errors"} and {"extensions"} are defined in the | |
| same way as an _execution result_ as described in the "Data", "Errors", and | |
| "Extensions" sections below. | |
| The value of the {"hasNext"} entry must be {false} | |
| if the initial incremental stream result is the last response of the incremental | |
| stream. Otherwise, {"hasNext"} must be {true}. |
I'd like to see a non-normative note below this explaining that {"hasNext"} is required only for it to be an initial incremental stream result, and that omitting it is valid if it's the only result, just that it means it's an execution result instead (i.e. there's no "incremental" at all). In this case, the GraphQL response would not return a stream.
This is a terrible version of that note since I'm writing this already over-time on our call...
Note: Omitting {"hasNext"} would make the response a regular execution result, which is valid only when returned directly and not as part of a stream.
There was a problem hiding this comment.
This suggested edit changes pending from required to optional on the initial incremental stream result, I don't think we have a case for an incremental stream without a pending? I will keep it as required when I incorporate this change.
Do you still think we need a note about omitting hasNext? it's a bit more complicated as you also need to omit pending?
I will however add a note explaining the reasoning for allowing hasNext: false in the initial incremental stream result
spec/Section 7 -- Response.md
Outdated
| The _initial incremental stream result_ may contain an entry with they key | ||
| {"incremental"}. The value of this entry must be a non-empty list of | ||
| _incremental result_. Each _incremental result_ must be a map as described in | ||
| the "Incremental Result" section below. |
There was a problem hiding this comment.
I'd add a non-normative note detailing why this is allowed.
There was a problem hiding this comment.
spec/Section 7 -- Response.md
Outdated
| The _initial incremental stream result_ must contain an entry with the key | ||
| {"pending"}. The value of this entry must be a non-empty list of _pending | ||
| result_. Each _pending result_ must be a map as described in the "Pending | ||
| Result" section below. |
There was a problem hiding this comment.
If "hasNext" is true, pending must be present.
If "hasNext" is false, pending must not be present. < Not true, could be hasNext:false along with pending:[...],incremental:[...],completed:[...]
There was a problem hiding this comment.
Going to leave this as is since pending must be present in all cases for the initial incremental stream result
spec/Section 7 -- Response.md
Outdated
| The _incremental stream update result_ may contain entries with keys | ||
| {"pending"}, {"incremental"}, and/or {"completed"}. The value of these entries | ||
| are defined in the same way as an _initial incremental stream result_ as | ||
| described in the "Pending Result", "Incremental Result", and "Completed Result" | ||
| sections below. |
There was a problem hiding this comment.
Should we add that {"hasNext": true} alone is invalid?
I propose that we do not do so. Not doing so allows {"hasNext: true} to be used as a keepalive.
There was a problem hiding this comment.
Agreed, do you think we should specifically mention this, outside of every other entry being defined as optional?
| clients, any of the maps described in the "Response" section (with the exception | ||
| of {"extensions"}) must not contain any entries other than those described | ||
| above. Clients must ignore any entries other than those described above. |
There was a problem hiding this comment.
We could probably upstream this change.
yaacovCR
left a comment
There was a problem hiding this comment.
This is amazing work, and others have given already and I’m sure we’ll continue to give wonderful feedback.
My two cents is that it may be beneficial to refer to the pending/completed and possibly even the incremental entries as notifications rather than results. The result is the deferred/streamed data at that path that has an id. It’s an abstract concept in terms of the response format, to be assembled, perhaps as needed, by the client.
The response can strictly speaking never send a pending result, in fact that’s in some sense an internal contradiction, or, at best, a shorthand for what we really mean, a notification or description of a result that is pending/completed. The incremental entries are actually results/updates, although calling them as such may confuse them with the overarching defer/stream result that they help complete.
I offer this comment just as a suggestion, I could live with this somewhat confusing shorthand if others feel that it is the best compromise in terms of clarity.
122ea6a to
6a6f38b
Compare
6a6f38b to
ffacdf4
Compare
Extracted from the full PR (#1110) and targeting an integration branch to aid in review.
The response section is especially important, as it defines all of the terms which will be used in the execution algorithm
Helpful reference material: