Skip to content
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

Report a maximum of one error per field in error response #981

Open
mz2 opened this issue Oct 17, 2020 · 1 comment
Open

Report a maximum of one error per field in error response #981

mz2 opened this issue Oct 17, 2020 · 1 comment

Comments

@mz2
Copy link

mz2 commented Oct 17, 2020

I may be misunderstanding something, but the error response behaviour in Absinthe appears to contradict the GraphQL spec. In https://github.com/absinthe-graphql/absinthe/blob/master/guides/errors.md it is stated that:

One or more errors for a field can be returned in a single {:error, error_value} tuple.

However, in the GraphQL specification (http://spec.graphql.org/June2018/#sec-Errors-and-Non-Nullability) the expected behaviour is stated as follows:

If the field returns null because of an error which has already been added to the "errors" list in the response, the "errors" list must not be further affected. That is, only one error should be added to the errors list per field.

Environment

The erroneous behaviour is documented behaviour with the present HEAD of master: https://github.com/absinthe-graphql/absinthe/blob/master/guides/errors.md

Expected behavior

A maximum of a single error should be populated per field as per the GraphQL spec.

Actual behavior

Any number of errors applicable for a given field is returned.

@benwilson512
Copy link
Contributor

Hi @mz2! I believe two things here:

  1. It is quite possible that you are right, and that in all cases, only one error should be reported per field.
  2. The part of the spec you are quoting does not say that.

The part of the spec you are quoting is explicitly about the situation of adding a nullability violation error. That is, if you have a field that is marked non_null in the schema, but you return an error for it, then this is also technically a second error: the result is nil for a field marked non_null. However the spec is saying not to add that second error.

I realize it contains the sentence: "That is, only one error should be added to the errors list per field." however given the context, I don't think it is clear that this is about all errors on all fields in all cases, and not just a comment about the specific extra error addressed in that situation. Are you able to find a clearer statement elsewhere in the spec about error counts per field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants