diff --git a/src/index.js b/src/index.js index a031932503..3b3e3ae834 100644 --- a/src/index.js +++ b/src/index.js @@ -243,7 +243,7 @@ export type { ExecutionResult, } from './execution'; -export { subscribe, createSubscriptionSourceEventStream } from './subscription'; +export { subscribe, createSourceEventStream } from './subscription'; // Validate GraphQL queries. export { diff --git a/src/subscription/index.js b/src/subscription/index.js index a5c82511f3..11b0a7f26d 100644 --- a/src/subscription/index.js +++ b/src/subscription/index.js @@ -1 +1 @@ -export { subscribe, createSubscriptionSourceEventStream } from './subscribe'; +export { subscribe, createSourceEventStream } from './subscribe'; diff --git a/src/subscription/subscribe.js b/src/subscription/subscribe.js index d44264bd21..3caa5b71ce 100644 --- a/src/subscription/subscribe.js +++ b/src/subscription/subscribe.js @@ -34,7 +34,16 @@ import type { OperationDefinitionNode, } from '../language/ast'; -export function createSubscriptionSourceEventStream( +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns an AsyncIterable + * + * A Source Stream represents the sequence of events, each of which is + * expected to be used to trigger a GraphQL execution for that event. + */ +export function createSourceEventStream( schema: GraphQLSchema, document: DocumentNode, rootValue?: mixed, @@ -63,7 +72,7 @@ export function createSubscriptionSourceEventStream( } /** - * Implements the "Subscribing to request" section of the GraphQL specification. + * Implements the "Subscribe" algorithm described in the GraphQL specification. * * Returns an AsyncIterator * @@ -78,7 +87,7 @@ export function subscribe( variableValues?: ?{[key: string]: mixed}, operationName?: ?string, ): AsyncIterator { - const subscription = createSubscriptionSourceEventStream( + const subscription = createSourceEventStream( schema, document, rootValue, @@ -138,6 +147,9 @@ function resolveSubscription( addPath(undefined, responseName) ); + // resolveFieldValueOrError implements the "ResolveFieldEventStream" + // algorithm from GraphQL specification. It differs from + // "ResolveFieldValue" due to providing a different `resolveFn`. const subscription = resolveFieldValueOrError( exeContext, fieldDef,