-
Notifications
You must be signed in to change notification settings - Fork 65
fix: context params and pass req and res in an object #1295
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BREAKING CHANGE: the incoming request and server response are now passed as a parameter object with `req` and `res` as key.
Thanks for your pragmatism. Agree developers have waited too long for improvement here. Please document the breaking change (also make it part of the commit message). When we polish the release notes we'll copy-paste it. |
jasonkuhrt
approved these changes
Jul 28, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #506
req
as first parameter, but an object withreq
res
as well as requested since quite a while by users. I know we said we didn't want addToContext to become a way to create server middleware and thus theres
didn't make a lot of sense. Still, we left that issue for months now and the priority is still not there, so I figured out adding it now would be best.TODO
BREAKING CHANGES:
The function passed to
schema.addToContext
(known as a "Context Adder") no longer has its first parameter being the request object. Instead it now receives an object (known as the "Context Adder Lens") containing the request object. In addition, on this lens, the response object can also be found. The lens exposes the request and response objects on propertiesreq
andres
respectively. If you feel strongly that they should berequest
andresponse
or any other thoughts you have please let us know on the issue tracker!before:
after: