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

refactor: small refactors within execute #3638

Merged
merged 4 commits into from
Jun 13, 2022

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Jun 12, 2022

This PR includes 3 small refactors for execute:

  1. move assertValidExecutionArguments into buildExecutionContext
  2. remove rootValue argument from executeOperation in favor of exeContext.rootValue
  3. pass ExecutionArgs through to buildExecutionContext within createSourceEventStream
  4. remove null from ‘executeOperation’ return type

…ntext`

`assertValidExecutionArguments` is only called immediately prior to `buildExecutionContext` and `buildExecutionContext` is never called without  calling `assertValidExecutionArguments` immediately prior.
`executeOperation` is never called with a `rootValue` different from `exeContext.rootValue` and `rootValue` is not utilized in the calling code except to pass its value to `executeOperation`. Rather than using an additional argument to `executeOperation`, the `rootValue`, the `rootValue` can be selected from the `exeContext` within `executeOperation`
@netlify
Copy link

netlify bot commented Jun 12, 2022

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 15dafb8
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/62a6473b2eb2ce00096a0ca5
😎 Deploy Preview https://deploy-preview-3638--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 June 12, 2022 18:20
@github-actions
Copy link

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 12, 2022
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`.
= `subscribe` now builds the `ExecutionContext` itself, calls the `createSourceEventStreamImpl` function on the original context and calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call
2. paves the way for enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 12, 2022
= introduces `buildPerEventExecutionContext` that creates an `ExecutionContext` for each subscribe event from the original `ExecutionContext` used to create the event stream
= `subscribe` now directly builds the `ExecutionContext` instead of relying on `createSourceEventStream`
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`
= `subscribe` calls the `createSourceEventStreamImpl` function on the original context and eventuallys calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call, reducing duplicate work
2. paves the way for easily enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
@yaacovCR yaacovCR added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Jun 12, 2022
@yaacovCR yaacovCR merged commit 35bc6a5 into graphql:main Jun 13, 2022
@yaacovCR yaacovCR deleted the small-refactors branch June 13, 2022 08:37
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 13, 2022
= introduces `buildPerEventExecutionContext` that creates an `ExecutionContext` for each subscribe event from the original `ExecutionContext` used to create the event stream
= `subscribe` now directly builds the `ExecutionContext` instead of relying on `createSourceEventStream`
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`
= `subscribe` calls the `createSourceEventStreamImpl` function on the original context and eventuallys calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call, reducing duplicate work
2. paves the way for easily enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 14, 2022
= introduces `buildPerEventExecutionContext` that creates an `ExecutionContext` for each subscribe event from the original `ExecutionContext` used to create the event stream
= `subscribe` now directly builds the `ExecutionContext` instead of relying on `createSourceEventStream`
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`
= `subscribe` calls the `createSourceEventStreamImpl` function on the original context and eventuallys calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call, reducing duplicate work
2. paves the way for easily enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 20, 2022
= introduces `buildPerEventExecutionContext` that creates an `ExecutionContext` for each subscribe event from the original `ExecutionContext` used to create the event stream
= `subscribe` now directly builds the `ExecutionContext` instead of relying on `createSourceEventStream`
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`
= `subscribe` calls the `createSourceEventStreamImpl` function on the original context and eventuallys calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call, reducing duplicate work
2. paves the way for easily enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 21, 2022
= introduces `buildPerEventExecutionContext` that creates an `ExecutionContext` for each subscribe event from the original `ExecutionContext` used to create the event stream
= `subscribe` now directly builds the `ExecutionContext` instead of relying on `createSourceEventStream`
= introduces `createSourceEventStreamImpl` and `executeImpl` functions that operate on the built `ExecutionContext` rather the `ExecutionArgs`
= `subscribe` calls the `createSourceEventStreamImpl` function on the original context and eventuallys calls `executeImpl` on the per event context created by `buildEventExecutionContext`.

Motivation:
1. remove unnecessary `buildExecutionContext` call, reducing duplicate work
2. paves the way for easily enhancing the `buildPerEventExecutionContext` to add a new `perEventContextFactory` argument to augment the context argument passed to resolvers as need per event.

depends on graphql#3638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: polish 💅 PR doesn't change public API or any observed behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants