-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to retrieve the error name as provided by the graphql server? #469
Comments
Since a lot of people will be using other keywords here as in I think that could solve the problem of having to handle x amount of keywords |
The PR that has been linked properly adds the I just wanted to leave a small clarification here to avoid any confusion :) In the GraphQL specification there’s a list of properties that are standardised to be sent as GraphQL errors, while raw strings as messages are allowed as well. The The JS library deals with this spec by having the This means that you have the option to use That being said, the most solid approach is to use explicit GraphQL errors on your backend which will be fully deserialised and to attach custom extensions to them. Hope that makes sense 👍 |
Amazing, thank you! |
Here's an example error response from my GraphQL server:
I would like to implement some logic in the frontend according to the error name (
TenantNotFoundError
) and not its message, but urql provides this to work with, which doesn't contain the error name:Is there any way to accomplish this?
I'd like to be able to do something like:
Matching errors by message, instead of some identifier (error name or code) seems pretty brittle to me and doesn't work well with internationalization.
Thank you.
The text was updated successfully, but these errors were encountered: