-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
subscribe: stay synchronous when possible (#3620)
This change aligns the return types of `execute` and `subscribe` (as well as `createSourceEventStream`) with respect to returning values or promises. Just as GraphQL execution for queries and mutations stays synchronous when possible, creation of the source event stream and returning the mapped `AsyncGenerator` will now occur synchronously when possible, i.e. when the `subscribe` method for the given subscription root field directly returns an `AsyncIterable`, rather than a Promise<AsyncIterable>. Specifically, the return types of `subscribe` and `createSourceEventStream` become: `subscribe(...): PromiseOrValue<AsyncGenerator<ExecutionResult> | ExecutionResult>` `createSourceEventStream(...): PromiseOrValue<AsyncIterable<unknown> | ExecutionResult>`. Previously, they were: `subscribe(...): Promise<AsyncGenerator<ExecutionResult> | ExecutionResult>`). `createSourceEventStream(...): Promise<AsyncIterable<unknown> | ExecutionResult>`. Co-authored-by: Ivan Goncharov <ivan.goncharov.ua@gmail.com>
- Loading branch information
1 parent
ea1894a
commit 6d42ced
Showing
2 changed files
with
161 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.