-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow resolvers to return multiple errors #1231
Allow resolvers to return multiple errors #1231
Conversation
Thanks for the detailed description in the issue and for proposing this fix, I'll take a close look soon! |
This fix looks good to me, do you mind adding a test case for it? You can either extend one of the (giant) fixture schemas that are already in the test suite, or you can write a small schema for testing this behavior in isolation, then demonstrate the new behavior that you added. That way, we can be sure it will keep working in the future! |
Will do, thanks for the suggestion (I thought about adding a test case with the original commit but felt disoriented within the test suite and wasn't sure where to start, I can go back and look at it now with more focus). update: done. I went for what I think made sense, but happy to fix/modify if you think the test belongs elsewhere or should look differently. |
test for a NonNull field returning more than one GraphQL::ExecutionError
I am curious, does this violate the spec?
http://facebook.github.io/graphql/October2016/#sec-Errors-and-Non-Nullability |
I am honestly confused by the wording in that spec. The errors key is a list of errors, the only required key is My take is that neither this PR (nor the existing add_error method) are a violation of the graphql specs, but @rmosolgo is the final arbiter in this. |
Here's a related issue in the reference implementation: graphql/graphql-js#205 |
Hmm, I suppose graphql-ruby already violates the spec in two ways:
In fact, graphql-ruby allows adding errors via
As @stanishev points out, this is already possible via multiple calls to So, I don't think this PR makes the violation any worse 😆 And of course, any user who doesn't wish to violate the spec in this way can simply use
|
This PR is to enable resolvers to return an array of
GraphQL::ExecutionError
s and to have the same behavior we see when a single GraphQL::ExecutionError is returned from a resolver.More detailed description here: #1230