-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
"GraphQL error" text string in error messages #1812
Comments
You can retrieve the actual error message from inside the ApolloError object, the message is mostly intended to be a summary for developers and differentiates between a graphql error and a network error. |
Is that supposed to work inside errors resulting from mutations, too? When I log out |
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client! |
@SachaG you can retrieve all of the GraphQL errors like this:
If you take a look here and open the console to the Frame, you can see the actual issue reported by the server |
@jbaxleyiii I actually ended up using https://github.com/thebigredgeek/apollo-errors instead. |
+1 When you have server-side validation error it's intuitive to use just Or make the prefix configurable and set it to |
Not sure why this is closed, I've been dazzled by this for the better part of the day trying to remove the prefix. The most common of use cases: I fire a mutation from within a component in a It's not hard to str.replace or introspect and get the original error for a couple of components but on a big app it's unmaintainable to have to do it everywhere manually. |
Gonna throw in another vote for removing this string, it results in |
For some reason mutations over websockets (subscriptions) don't return anything so I'm forced to run the mutation inside a try/catch block and parse the error from there. Unfortunately, this includes the silly 'Graphql error:' which I have to remove manually. |
Same thing here, :( |
I am also having this issue.. Would it not make more sense to simply set error to the actual error? |
I can see the value in differentiating GraphQL errors from network errors, but having to filter |
Google'd 'GraphQL error get message' and arrived here. Definitely unintuitive with the whole map thing. Error.message should return the actual message without the 'GraphQL Error:' part. |
I agree this should be configurable/overridden somewhere (maybe through |
Currently replacing the string myself manually too. This needs to be configurable. |
Made a client side helper method to remove the string... Can anyone with the back knowledge push so they remove it ? User doesn´t care about GraphQl and having to make such implementations either on the client side or a custom server side error code makes no sense. export function serverError(errorMsg) { Specially important for login and signup mutations where you use server side REGEX to validate inputs and throw errors if it fails. |
Seriously, please fix. |
+1 |
At first i thought this one coming from backend (i'm frontend guy). I get some complain from the user why error message contain this cryptic string that they don't understand (obviously they don't know what graphql is). I told backend team to change it, until they send link of this issues. Okay, then my fate has been sealed to fix this issues. I think this one need to be removed. If there some need to add this string for debugging process, we can always add additional variable for it. |
+1 |
I think the ability to customize/overwrite the error message would be well-placed into |
I think this is more of a GraphQL issue rather than Apollo but I may be wrong. I would try to get response from GraphQL team rather. But this issue is causing a headache on front-end. Anyone found any way around to change the string to an object? |
Why this is closed ? |
At least |
I'm also wondering why this was closed. |
I think it's safe to say that the community has spoken on this one, and that we should start looking into a different approach here. I've re-opened this issue - thanks all! |
[Object object]I've seen
https://codesandbox.io/s/4xn6pyl1r9 One thing that does cause it is creating an error with an object message, but that's how JS works: You'd have to stringify first: Stripping prefixI don't imagine devs wanting to show network errors, only graphql errors? In which case we could leave in the network prefix if we wanted? So
Or we could prefer consistency and strip
Thoughts? |
To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository. Migrated to: apollographql/apollo-feature-requests#46 |
I've noticed that all error messages passed on from apollo-client include the string "GraphQL error":
apollo-client/src/errors/ApolloError.ts
Line 20 in a80ed36
I'm wondering if this is really necessary? It's not a big deal (I can remove the string myself manually) but in some cases you might want to show an error message from the server when (for example) a mutation fails, and users who know nothing about GraphQL might get confused (I've had reports of "some kind of OpenGL error"… ;) )
The text was updated successfully, but these errors were encountered: