Closed machineghost closed 2 years ago
It’s unwise to add the request directly to the context because it only makes sense when using HTTP requests (e.g. it doesn’t make so much sense when using websockets, or in schema only usage). Instead I recommend you add accessor methods to the context that state what you wish to do rather than how you wish to do it (e.g. “logout()” rather than “req.session = null”).
Either way, you can use the additionalGraphQLContextFromRequest callback to add whatever things to context you need 👍
Summary
It can be useful to access the Request object for a request, for instance to access the
session
property of it (when usingexpress-sessions
). Normally the request is provided as part of the context argument to a resolver ... butmakeExtendSchemaPlugin
resolver functions get passed a context argument with norequest
property.Steps to reproduce
makeExtendSchemaPlugin
Query
orMutation
)request
Expected results
It should be possible to access the request
Actual results
It's not
Additional context
"postgraphile": "^4.10.0",
Possible Solution
It would seem trivial to just expose this, but I haven't looked at the source yet. If someone would point me in the right direction I'd be happy to submit a PR.