You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I'm migrating from express-graphql to graphql-http. The function customFormatErrorFn() from the former maps naturally to the latter's formatError(). However there are some differences in the codebase that I maintain, which make a direct migration a bit hard:
Before:
constmiddleware=graphqlHTTP(function(request,response,params){return{customFormatErrorFn(error){// I have access to request, response, params, including request.myContextrequest.context.logger.error("blabla");}};app.use('/some/path',middleware);
After:
constmiddleware=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. request.myContext.logger.info().
I'm trying to find a workaround with e.g. onSubscribe(), or by adding another middleware before or after, but haven't made it work yet.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I'm migrating from
express-graphql
tographql-http
. The functioncustomFormatErrorFn()
from the former maps naturally to the latter'sformatError()
. However there are some differences in the codebase that I maintain, which make a direct migration a bit hard:Before:
After:
In my specific use case, we're calling a logger as e.g.
request.myContext.logger.info()
.I'm trying to find a workaround with e.g.
onSubscribe()
, or by adding another middleware before or after, but haven't made it work yet.Any support is appreciated! Thanks!
Beta Was this translation helpful? Give feedback.
All reactions