ash_graphql/test/support/root_level_errors_schema.ex
Riccardo Binetti 70eae5f421
fix: make results nullable again if root level errors are enabled (#114)
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.
2024-02-09 09:36:23 -05:00

30 lines
522 B
Elixir

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