Skip to content

Commit 312017c

Browse files
Urigoleebyron
authored andcommitted
feat(subscriptions): added code comments (#858)
* feat(subscriptions): added code comments * Fix up comments
1 parent d00fbe9 commit 312017c

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export type {
243243
ExecutionResult,
244244
} from './execution';
245245

246-
export { subscribe, createSubscriptionSourceEventStream } from './subscription';
246+
export { subscribe, createSourceEventStream } from './subscription';
247247

248248
// Validate GraphQL queries.
249249
export {

src/subscription/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { subscribe, createSubscriptionSourceEventStream } from './subscribe';
1+
export { subscribe, createSourceEventStream } from './subscribe';

src/subscription/subscribe.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ import type {
3434
OperationDefinitionNode,
3535
} from '../language/ast';
3636

37-
export function createSubscriptionSourceEventStream(
37+
/**
38+
* Implements the "CreateSourceEventStream" algorithm described in the
39+
* GraphQL specification, resolving the subscription source event stream.
40+
*
41+
* Returns an AsyncIterable
42+
*
43+
* A Source Stream represents the sequence of events, each of which is
44+
* expected to be used to trigger a GraphQL execution for that event.
45+
*/
46+
export function createSourceEventStream(
3847
schema: GraphQLSchema,
3948
document: DocumentNode,
4049
rootValue?: mixed,
@@ -63,7 +72,7 @@ export function createSubscriptionSourceEventStream(
6372
}
6473

6574
/**
66-
* Implements the "Subscribing to request" section of the GraphQL specification.
75+
* Implements the "Subscribe" algorithm described in the GraphQL specification.
6776
*
6877
* Returns an AsyncIterator
6978
*
@@ -78,7 +87,7 @@ export function subscribe(
7887
variableValues?: ?{[key: string]: mixed},
7988
operationName?: ?string,
8089
): AsyncIterator<ExecutionResult> {
81-
const subscription = createSubscriptionSourceEventStream(
90+
const subscription = createSourceEventStream(
8291
schema,
8392
document,
8493
rootValue,
@@ -138,6 +147,9 @@ function resolveSubscription(
138147
addPath(undefined, responseName)
139148
);
140149

150+
// resolveFieldValueOrError implements the "ResolveFieldEventStream"
151+
// algorithm from GraphQL specification. It differs from
152+
// "ResolveFieldValue" due to providing a different `resolveFn`.
141153
const subscription = resolveFieldValueOrError(
142154
exeContext,
143155
fieldDef,

0 commit comments

Comments
 (0)