Skip to content

Commit

Permalink
Merge pull request #816 from binaryseed/single-error
Browse files Browse the repository at this point in the history
Match latest spec and return single error
  • Loading branch information
binaryseed committed Dec 7, 2019
2 parents 4043efe + 92a044e commit d84f6c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ For changes pre-v1.5 see the [v1.4](https://github.com/absinthe-graphql/absinthe
- Feature: Output rendered SDL for a schema
- Feature: Substantially lower subscription memory usage.
- Documentation: Testing guide, numerous fixes and updates
- Breaking Change: Scalar outputs are now type checked and will raise exceptions
if the result tries to send the wrong data type in the result.
- Breaking Change: Scalar outputs are now type checked and will raise exceptions if the result tries to send the wrong data type in the result.
- Breaking Change: `telemetry` event names [changed](https://github.com/absinthe-graphql/absinthe/pull/782) from the `alpha` to match an emerging naming convention for tracing.
- Breaking Change: Added phase to check validity of field names according to graphql spec. Might break existing schema's. Remove the `Absinthe.Phase.Schema.Validation.NamesMustBeValid` from the schema pipeline if you want to ignore this.
- Breaking Change: To match the GraphQL spec, we [no longer](https://github.com/absinthe-graphql/absinthe/pull/816) add a non-null error when a resolver on a non-null field explicitly returns it's own error.

## v1.5.0 (Alpha)

Expand Down
6 changes: 2 additions & 4 deletions lib/absinthe/phase/document/execution/resolution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ defmodule Absinthe.Phase.Document.Execution.Resolution do
|> propagate_null_trimming
end

defp maybe_add_non_null_error(errors, nil, %Type.NonNull{}) do
["Cannot return null for non-nullable field" | errors]
defp maybe_add_non_null_error([], nil, %Type.NonNull{}) do
["Cannot return null for non-nullable field"]
end

defp maybe_add_non_null_error(errors, _, _) do
Expand Down Expand Up @@ -354,8 +354,6 @@ defmodule Absinthe.Phase.Document.Execution.Resolution do
false
end

# defp maybe_add_non_null_error(errors, nil, %)

defp add_errors(result, errors, fun) do
Enum.reduce(errors, result, fun)
end
Expand Down
15 changes: 0 additions & 15 deletions test/absinthe/phase/execution/non_null_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ defmodule Absinthe.Phase.Document.Execution.NonNullTest do
data = %{"nullable" => %{"nullable" => nil}}

errors = [
%{
locations: [%{column: 25, line: 2}],
message: "Cannot return null for non-nullable field",
path: ["nullable", "nullable", "nonNullErrorField"]
},
%{
locations: [%{column: 25, line: 2}],
message: "boom",
Expand All @@ -142,11 +137,6 @@ defmodule Absinthe.Phase.Document.Execution.NonNullTest do
result = Absinthe.run(doc, Schema)

errors = [
%{
locations: [%{column: 23, line: 2}],
message: "Cannot return null for non-nullable field",
path: ["nonNull", "nonNull", "nonNullErrorField"]
},
%{
locations: [%{column: 23, line: 2}],
message: "boom",
Expand All @@ -168,11 +158,6 @@ defmodule Absinthe.Phase.Document.Execution.NonNullTest do
path = ["nullable", "nonNull", "nonNull", "nonNull", "nonNull", "nonNullErrorField"]

errors = [
%{
locations: [%{column: 54, line: 2}],
message: "Cannot return null for non-nullable field",
path: path
},
%{locations: [%{column: 54, line: 2}], message: "boom", path: path}
]

Expand Down

0 comments on commit d84f6c7

Please sign in to comment.