In my config, I have the following: -
expressGraphQL((req, res) => ({
...,
context: {
req,
res,
database,
},
}))
I would like to be able to pass res to a custom function in the context, like so: -
expressGraphQL((req, res) => ({
...,
context: {
req,
res,
database,
myCustomFunction: (res) => {
// do something with res object here
}
}))
However, when I get myCustomFunction from the context within a resolver and run is, res is undefined.
I am aware I can pull res out of the context along with myCustomFunction and invoke myCustomFunction(res) but I would like to just be able to do myCustomFunction().
Is there any way I can do this? Thanks.