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
I hope to be able to send something concise to the client, like:
{
..."extensions": {
"code": "INVALID_EMAIL""message": "Field is not an email",
"path": "userInput.email"
}
..."extensions": {
"code": "MIN_LENGH",
"message": "Field lenght is less than minimal",
"minLenght": 10,
"path": "userInput.name"
}
}
But not being forced to manually handle the same validation errors repeatedly on each resolver.
I've tried using validation middleware, but the error is already formatted, and it's hard to obtain error granular info and a unique code for each error.
The text was updated successfully, but these errors were encountered:
I have approached the same problem with a different solution: don't touch the transport (res.error & res.extensions fields), let the error be part of the handler response type:
mutation {
registerUser(email: ..., password: ...) {
errors # Any or custom Error scalaruser { id }
}
}
Is there any way to centralize every error format for the whole schema? I'm guessing about a middleware similar to:
I hope to be able to send something concise to the client, like:
But not being forced to manually handle the same validation errors repeatedly on each resolver.
I've tried using validation middleware, but the error is already formatted, and it's hard to obtain error granular info and a unique code for each error.
The text was updated successfully, but these errors were encountered: