-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Pass the context along to all the extension methods #1547
Conversation
@Whoaa512: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
Addresses #1343 With this change you should now be able to implement an extension like so: ```javascript class MyErrorTrackingExtension extends GraphQLExtension { willSendResponse(o) { const { context, graphqlResponse } = o context.trackErrors(graphqlResponse.errors) return o } } ```
The context shouldn't be necessary for format, parse, validation, and execute. Format generally outputs the state of the extension. Parse and validate don't depend on the context. Execution includes the context argument as contextValue
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.
I'm for this change. I think we need to make a decision going forward whether we want to be opinionated about what information goes in the context or specify the things that should go into these functions separately. For example, this would include information about client awareness and extensions to the query.
@Whoaa512 Thank you so much for the PR! |
I think there may be an alternative where |
Thanks a lot for this change, I am using to try some tracing integration and its working well so far. Is there any reason the context object was not added to the |
@cliedeman I think it might have just been on oversight on my part. Feel free to add another PR if your needs require it. |
Thanks, PR #1653 Created |
This is great and will fix issues I'm having with using sentry! Whats the normal release cadence for these things? |
* Pass the context along to all the extension methods Addresses #1343 With this change you should now be able to implement an extension like so: ```javascript class MyErrorTrackingExtension extends GraphQLExtension { willSendResponse(o) { const { context, graphqlResponse } = o context.trackErrors(graphqlResponse.errors) return o } } ``` Edit by @evans : fixes #1343 fixes #614 as the request object can be taken from context or from requestDidStart fixes #631 "" * Remove context from extra extension functions The context shouldn't be necessary for format, parse, validation, and execute. Format generally outputs the state of the extension. Parse and validate don't depend on the context. Execution includes the context argument as contextValue * Move change entry under vNext
Can anyone provide a small example of how to use this? I have not used extensions before - where do you provide them? |
@dauledk @maimike I wrote a small example of how to use this here: #1681 (comment) |
@seromenho could you shed some insight as to how this issue addresses #614 ? I'm not seeing how to access the context from the |
@twelve17 It doesn't expose the context to |
Addresses #1343
With this change you should now be able to implement an extension like so:
TODO:
Edit by @evans :
fixes #1343
fixes #614 as the request object can be taken from context or from requestDidStart
fixes #631 ""