Returns a Promise which resolves to either an AsyncIterator (if successful)
or an ExecutionResult (error). The promise will be rejected if the schema or
other arguments to this function are invalid, or if the resolved event stream
is not an async iterable.
If the client-provided arguments to this function do not result in a
compliant subscription, a GraphQL Response (ExecutionResult) with descriptive
errors and no data will be returned.
If the source stream could not be created due to faulty subscription resolver
logic or underlying systems, the promise will resolve to a single
ExecutionResult containing errors and no data.
If the operation succeeded, the promise resolves to an AsyncIterator, which
yields a stream of result representing the response stream.
Each result may be an ExecutionResult with no hasNext (if executing the
event did not use @defer or @stream), or an
InitialIncrementalExecutionResult or SubsequentIncrementalExecutionResult
(if executing the event used @defer or @stream). In the case of
incremental execution results, each event produces a single
InitialIncrementalExecutionResult followed by one or more
SubsequentIncrementalExecutionResults; all but the last have hasNext: true,
and the last has hasNext: false. There is no interleaving between results
generated from the same original event.
Implements the “Subscribe” algorithm described in the GraphQL specification, including
@defer
and@stream
as proposed in https://github.com/graphql/graphql-spec/pull/742Returns a Promise which resolves to either an AsyncIterator (if successful) or an ExecutionResult (error). The promise will be rejected if the schema or other arguments to this function are invalid, or if the resolved event stream is not an async iterable.
If the client-provided arguments to this function do not result in a compliant subscription, a GraphQL Response (ExecutionResult) with descriptive errors and no data will be returned.
If the source stream could not be created due to faulty subscription resolver logic or underlying systems, the promise will resolve to a single ExecutionResult containing
errors
and nodata
.If the operation succeeded, the promise resolves to an AsyncIterator, which yields a stream of result representing the response stream.
Each result may be an ExecutionResult with no
hasNext
(if executing the event did not use@defer
or@stream
), or anInitialIncrementalExecutionResult
orSubsequentIncrementalExecutionResult
(if executing the event used@defer
or@stream
). In the case of incremental execution results, each event produces a singleInitialIncrementalExecutionResult
followed by one or moreSubsequentIncrementalExecutionResult
s; all but the last havehasNext: true
, and the last hashasNext: false
. There is no interleaving between results generated from the same original event.Accepts an object with named arguments.