Unexpected error is not useful at all #1175
-
Sometimes, we do need to report the user(frontend) about the errors like missing auth token, the user does not exist, or bad requests at least in the console. I know that we can configure custom errors by using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you are not happy with how error masking works you can disable error masking and implement your own error handling through a plugin. import { createServer } from "@graphql-yoga/node"
createServer({
maskedErrors: false,
plugins: [
useYourCustomErrorHandlerPlugin(),
]
}).start() You can learn more about error masking in the tutorial or error masking documentation.
In general, I would recommend you model your expected errors as GraphQLObjectTypes using unions and/or interfaces. There is a great GraphQLWTF episode for this, GraphQL Error Handling with Union Types. I also wrote this article, Handling GraphQL errors like a champ with unions and interfaces, which showcases similar concepts. |
Beta Was this translation helpful? Give feedback.
If you are not happy with how error masking works you can disable error masking and implement your own error handling through a plugin.
You can learn more about error masking in the tutorial or error masking documentation.
In general, I would recommend you model your expected errors as GraphQLObjectTypes using…