-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make results nullable again if root level errors are enabled
Building upon #110, this restores the old behaviour of the result being nullable when root level errors are present. While the result is guaranteed to not be nullable in standard conditions (since either result or errors are always present), when errors are moved to the root level it could become null, so declaring it non-nullable propagates the null up to the data field. This actually causes compatibility problems with some client libraries (e.g. Relay) that expect the inner result to be null, _not_ data, if there's an error. This also adds dedicated RootLevelErrors versions of the Api and the Schema since the configuration is accessed at compile time now, so put_env was not enough to test them correctly.
- Loading branch information
Showing
4 changed files
with
119 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule AshGraphql.Test.RootLevelErrorsApi do | ||
@moduledoc false | ||
|
||
use Ash.Api, | ||
extensions: [ | ||
AshGraphql.Api | ||
], | ||
otp_app: :ash_graphql | ||
|
||
graphql do | ||
root_level_errors? true | ||
end | ||
|
||
resources do | ||
registry(AshGraphql.Test.Registry) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule AshGraphql.Test.RootLevelErrorsSchema do | ||
@moduledoc false | ||
|
||
use Absinthe.Schema | ||
|
||
@apis [AshGraphql.Test.RootLevelErrorsApi] | ||
|
||
use AshGraphql, apis: @apis | ||
|
||
query do | ||
end | ||
|
||
mutation do | ||
end | ||
|
||
object :foo do | ||
field(:foo, :string) | ||
field(:bar, :string) | ||
end | ||
|
||
input_object :foo_input do | ||
field(:foo, non_null(:string)) | ||
field(:bar, non_null(:string)) | ||
end | ||
|
||
enum :status do | ||
value(:open, description: "The post is open") | ||
value(:closed, description: "The post is closed") | ||
end | ||
end |