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

Simplfy concurrent resolver logic #294

Merged
merged 1 commit into from
Aug 21, 2018
Merged

Conversation

vektah
Copy link
Collaborator

@vektah vektah commented Aug 20, 2018

Before tackling #275 directly a little cleanup on concurrent resolvers is required. There currently isn't anywhere to add the required checks at the object level.

This pulls the concurrency logic out of individual graphql.Defer functions and moves it up into the object where we can put this bubbling logic. It also moves the recover function into the middleware stack, removing some duplicated code.

@vektah vektah merged commit 2c4e6cb into master Aug 21, 2018
@vektah vektah deleted the simplfy-concurrent-resolvers branch August 21, 2018 05:07
@dvic
Copy link
Contributor

dvic commented Aug 21, 2018

@vektah @mathewbyrne shouldn't each item in an array also be resolved in parallel? (see line here) If not, how would one otherwise benefit from using dataloader implementations? Or am I missing something?

I noticed this when I upgraded to 0.4.x, which caused approximately a 10x increase in the number of SQL queries.

@vektah
Copy link
Collaborator Author

vektah commented Aug 22, 2018

@dvic this PR hasn't made it to a tagged release yet, are you seeing this behaviour in 0.4.4?

Thanks for the heads up, I will do some more testing.

@dvic
Copy link
Contributor

dvic commented Aug 22, 2018

@vektah No, the behavior is introduced with this commit, 0.4.4 works fine (produces the same amount of queries as previous versions). It's because of the sync resolving of array elements (done here). This commit changes the behavior so that resolving a field blocks on returning a graphql.Marshaler, while previously this was not the case.

By the way: I have tried a parallel version of the for loop in question (commenting out rctx.PushIndex({{.index}}) and rctx.Pop()) and the number of queries is back to normal again. So it's definitely the cause of the problem.

@dvic
Copy link
Contributor

dvic commented Aug 23, 2018

@vektah should I open a ticket for this?

@vektah
Copy link
Collaborator Author

vektah commented Aug 23, 2018

If you like, I'm hoping to look at it tomorrow.

cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
…solvers

Simplfy concurrent resolver logic
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

3 participants