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

Match latest spec and return single error #816

Merged
merged 3 commits into from
Dec 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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