-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
commitMutation should return errors in onCompleted #2640
Comments
return {
errors: ['Error message']
} and then on outputFields: errors: {
type: GraphQLList(GraphQLString),
resolve: ({ errors }) => errors,
}, On client side, those |
Thanks for the fast reply! |
This would make it part of the |
What version of Relay are you using? Can you provide a sample GraphQL network response?
Kind of - the second (errors) argument to the onCompleted callback comes from the |
Also, if you're using react-relay-network-modern (without |
We are already dealing with Relays lack of implementing the GraphQL standard by mapping errors into data like so, but this is inside the
So how do I avoid avoid this, use |
|
If your server returns responses per the GraphQL specification (
|
Just to be clear, Relay does conform to the GraphQL spec and best practices - but I can understand confusion here, as the best practices for error handling in GraphQL have emerged over time. The GraphQL
There's a great writeup by @alloy on this approach as the final suggestion in http://artsy.github.io/blog/2018/10/19/where-art-thou-my-error/#Make.exceptions.first-class.citizens.of.your.schema. |
Ok, I cloned the ToDo MVC example So I guess I now have to find you where the errors are consumed 😭 |
First of all, why are Relay not just passing the data AND errors forward, huh? Could Relay Modern live up to its name? The We have a quite complex apps where we have a large three structure and multiple error scenarios, all errors are perfectly coded like: But we had to do this in
@leebyron left the building, now it is up to you to give this
This is a cute little app, they could have used REST 😂 |
Ok, I should stick to the topic/issue, and comment on other issues elsewhere. |
Ok, so I finally managed to track down the issue. Thanks for hinting me in the right direction! I have fixed the mapping and errors appear in |
However, it would be really nice if this was fixed: #1913 |
Seems like this can be closed then, as the original issue is not caused by Relay?
I’m not in any way speaking for the Relay team–this is just my personal OSS communication experience–, but yeah that’s probably helpful to your own cause. E.g. I’m not even sure what you mean by: “Could Relay Modern live up to its name?”, but it comes across as spiteful when in reality you’re asking somebody to help you with your issue when they have no obligation to do so. |
Ah, looks like it was closed while I was typing up my comment 👍 |
I sorry, no one has obligations to do so. New technology seems to give head scratching (with early adoption?), and Relay is no exception. I think my personal frustrations are with the documentation. Something appears supported when they are not, and basically I have to implement stuff with trail and error mindset. Mapping errors into data was not our first choice and we're still hoping for this to be solved. And, it goes both ways, the community feedback is just as resourceful as your help is to us. |
👍
Agreed, you're not alone on that one! Luckily after a lot of work by the Relay team and people in the community we're seeing a lot more movement in addressing non-FB needs; so welcome to the club and please do file PRs with doc improvements as you come across them! 🙏 |
Hi, I'm trying to propagate errors to the users that occurred in a
commitMutation
The following documentation does not really provide any info other that an array is returned in the
onCompleted
callback #commitMutation.Giving the code example,
errors
are undefind if an error occur on the server. I'm using a wrongid
on purpose (for testing) and the graphql server throws an error.Ok, so
onError
shows on errors, thats fine. Buterrors
areundefind
inonCompled
. Is this expected behaviour?The text was updated successfully, but these errors were encountered: