Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align return types from execution and subscription #3620

Merged
merged 6 commits into from
Jun 9, 2022

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.

= 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

@brainkim

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants