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

Fix batched queries context cloning #859

Merged
merged 2 commits into from Sep 1, 2022

Conversation

drakhart
Copy link
Contributor

fixes #858

  • Create a shallow copy of the context inside operationReq to make sure that context's top level properties are cloned and not just referenced.
  • Add more tests to make sure that the new context's top properties remain isolated through all the request lifecycle.

Request before the fix:
request_before

Request after the fix:
request_after

lib/routes.js Show resolved Hide resolved
@drakhart drakhart changed the title Properly clone context for batched queries Fix batched queries context cloning Aug 31, 2022
Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina requested a review from simoneb August 31, 2022 14:46

sinon.assert.calledTwice(onResolutionSpy)
sinon.assert.calledWith(onResolutionSpy, 0, 2, sinon.match(/TestQuery/))
sinon.assert.calledWith(onResolutionSpy, 1, 2, sinon.match(/DoubleQuery/))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same response, but this time at hook level instead of at resolver level.

@simoneb
Copy link
Collaborator

simoneb commented Sep 1, 2022

I'll go ahead and merge this

@simoneb simoneb merged commit 1e641bb into mercurius-js:master Sep 1, 2022
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.

Properly clone context for batched queries
4 participants