-
Hello! I'm migrating from Before: const middleware = graphqlHTTP(function (request, response, params) {
return {
customFormatErrorFn(error) {
// I have access to request, response, params, including request.myContext
request.context.logger.error("blabla");
}
};
app.use('/some/path', middleware); After: const middleware = createHandler({
formatError(error) {
// Have access to error, but not to request or context
}
});
app.use('/some/path', middleware); In my specific use case, we're calling a logger as e.g. I'm trying to find a workaround with e.g. Any support is appreciated! Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
At the moment, this syntax is not supported. This could be a good feature to add though. However, you can achieve the same thing by using the createHandle IIFE style: - const middleware = createHandler({
+ const middleware = (request, response, params) => createHandler({
formatError(error) {
// Have access to error and request or context
}
- });
+ })(request, response, params);
app.use('/some/path', middleware); Since the creation of the handler is a cheap operation, this should not cause any issues performance-wise. |
Beta Was this translation helpful? Give feedback.
At the moment, this syntax is not supported. This could be a good feature to add though.
However, you can achieve the same thing by using the createHandle IIFE style:
Since the creation of the handler is a cheap operation, this should not cause any issues performance-wise.