@@ -89,32 +89,42 @@ yielded by an _incremental stream_.
8989
9090An _ initial incremental stream result_ must be a map.
9191
92- The _ initial incremental stream result_ must contain an entry with key {"data"},
93- and may contain entries with keys {"errors"} and {"extensions"}. The value of
94- these entries are defined in the same way as an _ execution result_ as described
95- in the "Data", "Errors", and "Extensions" sections below.
96-
97- The _ initial incremental stream result_ must contain an entry with the key
98- {"hasNext"}. The value of this entry must be {true} if there are any
99- _ incremental stream update results_ in the _ incremental stream_ . The value of
100- this entry must be {false} if the initial incremental stream result is the last
101- response of the incremental stream.
102-
103- The _ initial incremental stream result_ must contain an entry with the key
104- {"pending"}. The value of this entry must be a non-empty list of _ pending
105- result_ . Each _ pending result_ must be a map as described in the "Pending
106- Result" section below.
92+ The _ initial incremental stream result_ must contain entries with keys {"data"},
93+ {"pending"}, and {"hasNext"}, and may contain entries with keys {"errors"},
94+ {"incremental"}, {"completed"}, and {"extensions"}.
95+
96+ The value of {"data"}, {"errors"} and {"extensions"} are defined in the same way
97+ as an _ execution result_ as described in the "Data", "Errors", and "Extensions"
98+ sections below.
99+
100+ The value of {"hasNext"} must be {false} if the initial incremental stream
101+ result is the last response of the incremental stream. Otherwise, {"hasNext"}
102+ must be {true}.
107103
108- The _ initial incremental stream result_ may contain an entry with they key
109- {"incremental"}. The value of this entry must be a non-empty list of
104+ The value of {"pending"} must be a non-empty list of _ pending result_ . Each
105+ _ pending result_ must be a map as described in the "Pending Result" section
106+ below.
107+
108+ The value of {"incremental"}, if present, must be a non-empty list of
110109_ incremental result_ . Each _ incremental result_ must be a map as described in
111110the "Incremental Result" section below.
112111
113- The _ initial incremental stream result_ may contain an entry with they key
114- {"completed"}. The value of this entry must be a non-empty list of _ completed
112+ The value of {"completed"}, if present, must be a non-empty list of _ completed
115113result_ . Each _ completed result_ must be a map as described in the "Completed
116114Result" section below.
117115
116+ Note: A GraphQL service is permitted to include incrementally delivered data in
117+ the _ initial incremental stream_ . For example, A GraphQL middleware layer, such
118+ as a caching CDN or proxy service, may wish to intercept and rewrite the
119+ _ incremental stream_ before delivering it to a client. This service may collect
120+ some or all of the _ pending result_ , _ incremental result_ , and _ completed
121+ result_ from the entire _ incremental stream_ of the upstream service, and
122+ construct a new incremental stream containing a single payload: an _ initial
123+ incremental stream result_ containing the all of the intercepted pending
124+ results, incremental results, and completed results, and the {"hasNext"} entry
125+ set to false. This would allow the client to efficiently render the entire
126+ result without having to process multiple payloads.
127+
118128### Incremental Stream Update Result
119129
120130:: An _ incremental stream update result_ contains the result of executing any
@@ -125,23 +135,22 @@ must be incremental stream update results.
125135
126136An _ incremental stream update result_ must be a map.
127137
128- Unlike the _ initial incremental stream result_ , an _ incremental stream update
129- result_ must not contain entries with keys {"data"} or {"errors"}.
138+ The _ incremental stream update result_ must contain an entry with the key
139+ {"hasNext"}, and may contain entries with the keys {"pending"}, {"incremental"},
140+ {"completed"}, and {"extensions"}. Unlike the _ initial incremental stream
141+ result_ , an _ incremental stream update result_ must not contain entries with
142+ keys {"data"} or {"errors"}.
130143
131- An _ incremental stream update result_ may contain an entry with the key
132- {"extensions"}. The value of this entry is described in the "Extensions"
133- section.
144+ The value of {"hasNext"} must be {true} for all but the last response in the
145+ _ incremental stream_ . Otherwise, {"hasNext"} must be {true}.
134146
135- An _ incremental stream update result _ must contain an entry with the key
136- {"hasNext"}. The value of this entry must be {true} for all but the last
137- response in the _ incremental stream _ . The value of this entry must be {false}
138- for the last response of the incremental stream .
147+ The value of {"pending"}, {"incremental"}, and/or {"completed"}, if present are
148+ defined in the same way as an _ initial incremental stream result _ as described
149+ in the "Pending Result", "Incremental Result", and "Completed Result" sections
150+ below .
139151
140- The _ incremental stream update result_ may contain entries with keys
141- {"pending"}, {"incremental"}, and/or {"completed"}. The value of these entries
142- are defined in the same way as an _ initial incremental stream result_ as
143- described in the "Pending Result", "Incremental Result", and "Completed Result"
144- sections below.
152+ The value of {"extensions"}, if present, is defined in the same way as an
153+ _ execution result_ as described in the "Extensions" section below.
145154
146155### Response Position
147156
@@ -167,7 +176,7 @@ represents a path in the response, not in the request.
167176When a _ response path_ is present on an _ error result_ , it identifies the
168177_ response position_ which raised the error.
169178
170- When a _ response path_ is present on an _ incremental result_ , it identifies the
179+ When a _ response path_ is present on a _ pending result_ , it identifies the
171180_ response position_ of the incremental data update.
172181
173182A single field execution may result in multiple response positions. For example,
@@ -418,21 +427,23 @@ either the current response, or one of the following responses.
418427
419428A _ pending result_ must be a map.
420429
421- Every _ pending result_ must contain an entry with the key {"id"} with a string
422- value. This {"id"} should be used by clients to correlate pending results with
423- _ incremental result_ and _ completed result_ . The {"id"} value must be unique for
424- the entire _ incremental stream_ response. There must not be any other pending
425- result in the _ incremental stream_ that contains the same {"id"}.
426-
427- Every _ pending result_ must contain an entry with the key {"path"}. When the
428- pending result is associated with a ` @stream ` directive, it indicates the list
429- at this _ response position_ is not known to be complete. Clients should expect
430- the GraphQL Service to incrementally deliver the remainder list items of this
431- list. When the pending result is associated with a ` @defer ` directive, it
432- indicates that the response fields contained in the deferred fragment are not
433- known to be complete. Clients should expect the GraphQL Service to incrementally
434- deliver the remainder of the fields contained in the deferred fragment at this
435- _ response position_ .
430+ A _ pending result_ must contain entries with the keys {"id"} and {"path"}, and
431+ may contain an entry with key {"label"}.
432+
433+ The value of {"id"} must be a string. This {"id"} should be used by clients to
434+ correlate pending results with _ incremental result_ and _ completed result_ . The
435+ {"id"} value must be unique across the entire _ incremental stream_ response.
436+ There must not be any other pending result in the _ incremental stream_ with the
437+ same {"id"}.
438+
439+ The value of {"path"} must be a _ response position_ . When the pending result is
440+ associated with a ` @stream ` directive, it indicates the list at this _ response
441+ position_ is not known to be complete. Clients should expect the GraphQL Service
442+ to incrementally deliver the remainder list items of this list. When the pending
443+ result is associated with a ` @defer ` directive, it indicates that the response
444+ fields contained in the deferred fragment are not known to be complete. Clients
445+ should expect the GraphQL Service to incrementally deliver the remainder of the
446+ fields contained in the deferred fragment at this _ response position_ .
436447
437448If the associated ` @defer ` or ` @stream ` directive contains a ` label ` argument,
438449the pending result must contain an entry {"label"} with the value of this
@@ -445,14 +456,9 @@ this data, and the data can be found either in the {"data"} entry in the
445456_ initial incremental stream result_ , or one of the prior _ incremental stream
446457update result_ in the _ incremental stream_ .
447458
448- :: The _ associated pending result_ is a specific _ pending result_ associated
449- with any given _ incremental result_ or _ completed result_ . The associated
450- pending result can be determined by finding the pending result where the value
451- of its {"id"} entry is the same value of the {"id"} entry of the given
452- incremental result or completed result. The associated pending result must
453- appear in the _ incremental stream_ , in the same or prior _ initial incremental
454- stream result_ or _ execution update result_ as the given incremental result or
455- completed result.
459+ :: The _ associated pending result_ of an _ incremental result_ or _ completed
460+ result_ is the _ pending result_ whose {"id"} entry has the same value as the
461+ {"id"} entry of the given incremental result or completed result.
456462
457463### Incremental Result
458464
@@ -462,10 +468,11 @@ _incremental list result_ or an _incremental object result_.
462468
463469An _ incremental result_ must be a map.
464470
465- Every _ incremental result_ must contain an entry with the key {"id"} with a
466- string value. The definition of _ associated pending result_ describes how this
467- value is used to determine the associated pending result for a given
468- _ incremental result_ .
471+ Every _ incremental result_ must contain an entry with the key {"id"}, the value
472+ of which is a string referencing its _ associated pending result_ . The associated
473+ pending result must appear either in the _ initial incremental stream result_ , in
474+ a prior _ incremental stream update result_ , or in the same _ incremental stream
475+ update result_ as the _ incremental result_ that references it.
469476
470477#### Incremental List Result
471478
@@ -479,25 +486,25 @@ from its _associated pending result_.
479486
480487** Incremental List Result Format**
481488
482- Every _ incremental list result_ must contain an entry with the key {"id"}, used
483- to determine the _ associated pending result_ for this _ incremental result_ .
484-
485489Every _ incremental list result_ must contain an {"items"} entry. The {"items"}
486490entry must contain a list of additional list items for the list field in the
487491incremental list result's _ response position_ . The value of this entry must be a
488492list of the same type of the response field at this _ response position_ .
489493
490494If any _ execution error_ were raised during the execution of the results in
491- {"items"} and these errors propagate to a _ response position_ higher than the
492- _ incremental list result_ 's response position, the incremental list result is
493- considered failed and should not be included in the _ incremental stream_ . The
494- errors that caused this failure will be included in a _ completed result_ .
495+ {"items"} and these errors propagate to the _ response position_ of the
496+ _ incremental list result_ (i.e. the streamed list), or a parent response
497+ position of the incremental list result's response position (i.e. a parent of
498+ the streamed list), the incremental list result is considered failed and should
499+ not be included in the _ incremental stream_ . The errors that caused this failure
500+ will be included in a _ completed result_ .
495501
496502If any _ execution error_ were raised during the execution of the results in
497- {"items"} and these errors did not propagate to a path higher than the
498- _ incremental list result_ 's path, the incremental list result must contain an
499- entry with key {"errors"} containing these execution errors. The value of this
500- entry is described in the "Errors" section.
503+ {"items"} and no such error propagated to the _ response position_ of the
504+ _ incremental list result_ , or a parent response position of the incremental list
505+ result's response position, the incremental list result must contain an entry
506+ with key {"errors"} containing these execution errors. The value of this entry
507+ is described in the "Errors" section.
501508
502509#### Incremental Object Result
503510
@@ -508,34 +515,38 @@ result_ must be associated with a `@defer` directive.
508515
509516** Incremental Object Result Format**
510517
511- The _ incremental object result_ may contain a {"subPath"} entry. If this entry
512- is present, the incremental object result's _ response position _ can be
513- determined by concatenating the value of the _ associated pending result _ 's
514- {"path"} entry with the value of this {"subPath"} entry . If no {"subPath"} entry
515- is present, the _ response position_ is the value of the associated pending
516- result's {"path"} entry.
518+ The _ incremental object result_ may contain a {"subPath"} entry. If such an
519+ entry is present, the _ response position _ of the incremental object result is
520+ the result of appending the value of this {"subPath"} to the value of the
521+ {"path"} entry of the _ associated pending result _ . If no {"subPath"} entry is
522+ present, the _ response position_ is the value of the associated pending result's
523+ {"path"} entry.
517524
518525An _ incremental object result_ may be used to deliver data for response fields
519- that were contained in more than one deferred fragments. In that case, the
520- _ associated pending result_ of the incremental object result must be a _ pending
521- result_ with the longest {"path"}.
526+ that were contained in more than one deferred fragment.
527+
528+ In that case, the _ associated pending result_ of the incremental object result
529+ must be one of the _ pending result_ that corresponding to a fragment that
530+ contained the delivered responsive fields. If any of these pending results have
531+ a {"path"} of varying length, one of the pending results with the longest
532+ {"path"} must be chosen to minimize the size of the {"subPath"}.
522533
523534Every _ incremental object result_ must contain a {"data"} entry. The {"data"}
524535entry must contain a map of additional response fields. The {"data"} entry in an
525536incremental object result will be of the type of the field at the incremental
526537object result's _ response position_ .
527538
528539If any _ execution error_ were raised during the execution of the results in
529- {"data"} and these errors propagated to a _ response position_ higher than the
540+ {"data"} and these errors propagated to a parent _ response position_ of the
530541_ incremental object result_ 's response position, the incremental object result
531542is considered failed and should not be included in the incremental stream. The
532- errors that caused this failure will be included in a _ completed result_ .
543+ error that caused this failure will be included in a _ completed result_ .
533544
534545If any _ execution error_ were raised during the execution of the results in
535- {"data"} and these errors did not propagate to a _ response position_ higher than
536- the _ incremental object result_ 's response position, the incremental object
537- result must contain an entry with key {"errors"} containing these execution
538- errors. The value of this entry is described in the "Errors" section.
546+ {"data"} and no such error propagated to a parent _ response position_ of the
547+ _ incremental object result_ 's response position, the incremental object result
548+ must contain an entry with key {"errors"} containing these execution errors. The
549+ value of this entry is described in the "Errors" section.
539550
540551### Completed Result
541552
@@ -549,16 +560,20 @@ which this completed result appears.
549560
550561A _ completed result_ must be a map.
551562
552- Every _ completed result_ must contain an entry with the key {"id"} with a string
553- value. The definition of _ associated pending result_ describes how this value is
554- used to determine the associated pending result for a given _ completed result_ .
563+ A _ completed result_ must contain an entry with the key {"id"}, and may contain
564+ an entry with the key {"errors"}.
565+
566+ The value of {"id"} must be a string referencing its _ associated pending
567+ result_ . The associated pending result must appear either in the _ initial
568+ incremental stream result_ , in a prior _ incremental stream update result_ , or in
569+ the same _ incremental stream update result_ as the _ completed result_ that
570+ references it.
555571
556- A _ completed result_ may contain an {"errors"} entry. When the {"errors"} entry
557- is present, it informs clients that the delivery of the data from the
558- _ associated pending result_ has failed, due to an execution error propagating to
559- a _ response position_ higher than the _ incremental result_ 's response position.
560- The {"errors"} entry must contain these execution errors. The value of this
561- entry is described in the "Errors" section.
572+ The value of {"errors"}, if present, informs clients that the delivery of the
573+ data from the _ associated pending result_ has failed, due to an execution error
574+ propagating to a parent _ response position_ of the _ incremental result_ 's
575+ response position. The {"errors"} entry must contain these execution errors. The
576+ value of this entry is described in the "Errors" section.
562577
563578### Additional Entries
564579
0 commit comments