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

Properly name the root field execution functions #3294

Closed
wants to merge 2 commits into from

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Oct 7, 2021

The codebase should refer to functions that execute the query, mutation, and/or subscription root fields as such, rather than as functions that execute the operations themselves. Executing a query or mutation returns a map of data and errors, while executing the root fields returns the completed value of the root fields.

Depends on #3306

Base automatically changed from remove-from-try-block to main October 9, 2021 08:57
@yaacovCR
Copy link
Contributor Author

It looks like squash merging #3295 into #3294 has caused merge conflicts in the remainder of the stack. I can rebase the remainder of the PR stack, but maybe you can just redo the merge as individual commits or merge #3294 into main first.

Let me know how I can expedite here.

@yaacovCR
Copy link
Contributor Author

I’m not sure the overall merge/review strategy, I prepared this stack as individual PRs that could each get merged into main. If there is some other way you want to organize, please let me know how I can help. My only goal is to expedite/facilitate your review and hopefully merging these changes as soon as possible.

@yaacovCR
Copy link
Contributor Author

That is, each could be merged into main consecutively. Maybe you meant to merge #3295 into main?

@IvanGoncharov
Copy link
Member

@yaacovCR Yes, my mistake.
Can you create changes from #3295 as separate out-of-stack PR?
Happy to merge it.

@yaacovCR
Copy link
Contributor Author

I can, sure, but not until several hours from now. Are you able in the meantime to proceed with review? In particular #3294 should be uncontroversial now, as do the rest of them (in my opinion).

@IvanGoncharov
Copy link
Member

@yaacovCR I was looking into execute.ts more and notice a bug + opportunity fold subscribe into execute.
It's super weird that both graphql & execute execute subscription operations as queries.
Since we will need to support AsyncIterator as return value for both functions (to implement @stream/@defer) it totally makes sense to fold subscribe into execute.
I will submit a few PRs today to show what I mean.
I will ping you once finish, so you don't need to rebase multiple times.

@yaacovCR yaacovCR changed the base branch from main to broaden-execution-again October 11, 2021 14:24
The codebase should refer to functions that execute the query, mutation, and/or subscription root fields as such, rather than as functions that execute the operations themselves. Executing a query or mutation returns a map of data and errors, while executing the root fields returns the data of the root fields.
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Oct 11, 2021

I will ping you once finish, so you don't need to rebase multiple times.

I rebased everything. It's all ready to review and merge.

Base automatically changed from broaden-execution-again to main October 11, 2021 15:08
exeContext: ExecutionContext,
operation: OperationDefinitionNode,
rootValue: unknown,
): PromiseOrValue<ObjMap<unknown> | null> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context is a necessary evil, for stuff used deeply in the call chain.
If arguments are used directly we should pass them directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially, since a plan is to separate operation execution context later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debatable, but Ok

@@ -190,7 +190,7 @@ export async function createSourceEventStream(
}
}

async function executeSubscription(
async function executeSubscriptionRootField(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep, naming for now.
It's better to refactor them to return proper response once we separate operation execution context.
We can add TODO or FIXME to make it clearer.
Just don't want to rename stuff prematurly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above, disagree strongly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing premature about correcting an error, just because you will further improve later, this is internal code refactoring, non breaking changes, you can rererename as often as you want

*/
function executeOperation(
function executeQueryOrMutationRootFields(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed previously want to put subscription here.
So let's keep the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name as now is incorrect, for internal refactoring, better to just improve instead of adding todo to get optimal solution. There is a saying, “perfect is the enemy of good.”

@yaacovCR
Copy link
Contributor Author

As per our offline discussion, I am forking the executor only and will be pushing forward asap with class based Executor over there, in order to jumpstart experimentation. Hopefully whatever works at graphql-executor can be integrated upstream as desired.

yaacovCR#1

@yaacovCR yaacovCR closed this Oct 13, 2021
@yaacovCR yaacovCR deleted the execute-root-fields branch September 7, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants