@@ -164,7 +164,7 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
164164
165165### Subscription
166166
167- If the operation is a subscription, the result is an event stream called the
167+ If the operation is a subscription, the result is an _ event stream _ called the
168168"Response Stream" where each event in the event stream is the result of
169169executing the operation for each new event on an underlying "Source Stream".
170170
@@ -217,18 +217,21 @@ chat room ID is the "topic" and each "publish" contains the sender and text.
217217
218218** Event Streams**
219219
220- An event stream represents a sequence of discrete emitted events over time which
221- can be observed. As an example, a "Pub-Sub" system may produce an event stream
222- when "subscribing to a topic", with an event emitted for each "publish" to that
223- topic.
220+ :: An _ event stream _ represents a sequence of events: discrete emitted values
221+ over time which can be observed. As an example, a "Pub-Sub" system may produce
222+ an _ event stream _ when "subscribing to a topic", with an value emitted for each
223+ "publish" to that topic.
224224
225- Event streams may complete at any point, often because no further events will
226- occur. Event streams may emit an infinite sequence of events , in which they may
227- never complete. If an event stream encounters an error, it must complete with
228- that error.
225+ An _ event stream _ may complete at any point, often because no further events
226+ will occur. An _ event stream _ may emit an infinite sequence of values , in which
227+ it may never complete. If an _ event stream _ encounters an error, it must
228+ complete with that error.
229229
230- An observer may at any point decide to stop observing an event stream by
231- cancelling it. When an event stream is cancelled, it must complete.
230+ An observer may at any point decide to stop observing an _ event stream_ by
231+ cancelling it. When an _ event stream_ is cancelled, it must complete.
232+
233+ Internal user code also may cancel an _ event stream_ for any reason, which would
234+ be observed as that _ event stream_ completing.
232235
233236** Supporting Subscriptions at Scale**
234237
@@ -254,8 +257,8 @@ service details should be chosen by the implementing service.
254257
255258#### Source Stream
256259
257- A Source Stream represents the sequence of events, each of which will trigger a
258- GraphQL execution corresponding to that event . Like field value resolution, the
260+ A Source Stream is an _ event stream _ representing a sequence of root values,
261+ each of which will trigger a GraphQL execution . Like field value resolution, the
259262logic to create a Source Stream is application-specific.
260263
261264CreateSourceEventStream(subscription, schema, variableValues, initialValue):
@@ -280,7 +283,7 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
280283ResolveFieldEventStream(subscriptionType, rootValue, fieldName, argumentValues):
281284
282285- Let {resolver} be the internal function provided by {subscriptionType} for
283- determining the resolved event stream of a subscription field named
286+ determining the resolved _ event stream _ of a subscription field named
284287 {fieldName}.
285288- Return the result of calling {resolver}, providing {rootValue} and
286289 {argumentValues}.
@@ -291,24 +294,34 @@ operation type.
291294
292295#### Response Stream
293296
294- Each event in the underlying Source Stream triggers execution of the
295- subscription _ selection set_ using that event as a root value .
297+ Each event from the underlying Source Stream triggers execution of the
298+ subscription _ selection set_ using that event's value as the {initialValue} .
296299
297300MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
298301
299- - Let {responseStream} be a new event stream .
300- - When {sourceStream} emits {event }:
302+ - Let {responseStream} be a new _ event stream _ .
303+ - When {sourceStream} emits {sourceValue }:
301304 - Let {response} be the result of running
302- {ExecuteSubscriptionEvent(subscription, schema, variableValues, event)}.
303- - Emit {response} on {responseStream}.
305+ {ExecuteSubscriptionEvent(subscription, schema, variableValues,
306+ sourceValue)}.
307+ - If internal {error} was raised:
308+ - Cancel {sourceStream}.
309+ - Complete {responseStream} with {error}.
310+ - Otherwise emit {response} on {responseStream}.
304311- When {sourceStream} completes normally:
305312 - Complete {responseStream} normally.
306313- When {sourceStream} completes with {error}:
307314 - Complete {responseStream} with {error}.
308315- When {responseStream} is cancelled:
309316 - Cancel {sourceStream}.
317+ - Complete {responseStream} normally.
310318- Return {responseStream}.
311319
320+ Note: Since {ExecuteSubscriptionEvent()} handles all _ field error_ , and _ request
321+ error_ only occur during {CreateSourceEventStream()}, the only remaining error
322+ condition handled from {ExecuteSubscriptionEvent()} are internal exceptional
323+ errors not described by this specification.
324+
312325ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
313326
314327- Let {subscriptionType} be the root Subscription type in {schema}.
0 commit comments