Skip to content

Conversation

@yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented May 31, 2022

with respect to possible promises

motivations:

  1. no need to enter event loop unnecessarily
  2. further step toward integration of subscribe workflow into execute
@netlify
Copy link

netlify bot commented May 31, 2022

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 6714bbe
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/62a24882d5e85b000814bddd
😎 Deploy Preview https://deploy-preview-3620--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@yaacovCR yaacovCR requested a review from a team May 31, 2022 12:22
@yaacovCR yaacovCR added the PR: breaking change 💥 implementation requires increase of "major" version number label May 31, 2022
@yaacovCR yaacovCR force-pushed the align branch 2 times, most recently from a735422 to b0e56f2 Compare June 7, 2022 07:45
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 7, 2022
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
@yaacovCR yaacovCR force-pushed the align branch 2 times, most recently from d89e2de to 7f214ea Compare June 7, 2022 10:17
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jun 7, 2022

because this depends on #3630 the diff to review (until #3630 is merged) would be here:

yaacovCR/graphql-js@extract...align

@yaacovCR yaacovCR force-pushed the align branch 2 times, most recently from 2321ee8 to 3b27fb6 Compare June 7, 2022 11:40
IvanGoncharov pushed a commit that referenced this pull request Jun 8, 2022
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from #3620
with respect to possible promises
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jun 8, 2022

@IvanGoncharov @graphql/graphql-js-reviewers

This has been rebased and is re-ready for review.

yaacovCR added 3 commits June 9, 2022 21:58
= remove unnecessary waits = simply subscribeWithBadFn
until it is asserted as eventStream
@yaacovCR yaacovCR merged commit 6d42ced into graphql:main Jun 9, 2022
@yaacovCR yaacovCR deleted the align branch June 9, 2022 19:41
@yaacovCR
Copy link
Contributor Author

See further discussion with respect to advantages of using repeaters about general anti pattern of Promise<AsyncIterator>

@yaacovCR
Copy link
Contributor Author

yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 11, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
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>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`. This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function. For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered. extracted from graphql#3620
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: breaking change 💥 implementation requires increase of "major" version number

2 participants