Skip to content

Commit 75f10e0

Browse files
committed
feedback and use definition syntax
1 parent 5bb1e07 commit 75f10e0

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

spec/Section 2 -- Language.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ There are three types of operations that GraphQL models:
288288

289289
- query - a read-only fetch.
290290
- mutation - a write followed by a fetch.
291-
- subscription - a long-lived request that fetches data in response to source
292-
events.
291+
- subscription - a long-lived request that fetches data in response to a
292+
sequence of events over time.
293293

294294
Each operation is represented by an optional operation name and a _selection
295295
set_.

spec/Section 6 -- Execution.md

+33-20
Original file line numberDiff line numberDiff line change
@@ -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
169169
executing 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
259262
logic to create a Source Stream is application-specific.
260263

261264
CreateSourceEventStream(subscription, schema, variableValues, initialValue):
@@ -280,7 +283,7 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
280283
ResolveFieldEventStream(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

297300
MapSourceToResponseEvent(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+
312325
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
313326

314327
- Let {subscriptionType} be the root Subscription type in {schema}.

0 commit comments

Comments
 (0)