|
I'm tying to make an graphQL endpoint in a already existing express project, Have a authentication middleware that evaluates the token and attach user object to req (req.user) I want to be able to get this user in the resolver. example: if I import createHandler like this
req.user is undefined but if I import createHanlder like this:
I get req.user correctly but, the endpoints gives me timeout. What is the proper way to do this?? Thanks so much in advance. |
Answered by
enisdenjo
Jan 17, 2025
Replies: 1 comment
|
The request of the underlying server is inside the router.post(
'/business2',
createHandler({
schema: schema2,
rootValue: root2,
context: (req) => ({
- user: req.user
+ user: req.raw.user
})
// Pass req.user into the context,
})
); |
0 replies
Answer selected by
yosletpp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The request of the underlying server is inside the
rawproperty.router.post( '/business2', createHandler({ schema: schema2, rootValue: root2, context: (req) => ({ - user: req.user + user: req.raw.user }) // Pass req.user into the context, }) );