How to access the request object inside a GraphQL resolver (using Apollo-Server-Express)
The request object should be accessed through the context. You can modify the options passed to your graphqlExpress middleware to define your context, like this:
server.use('/graphql', bodyParser.json(), graphqlExpress(req => ({ schema, context: { user: req.user }}))
I know express-graphql
actually uses the request as the context if it's not defined in the options -- Apollo's middleware may very well behave the same way but that's unclear for the documentation.
Finally, the context is then available as the third parameter passed to your resolver function.