File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ defmodule AshGraphql do
518518 type: action . returns ,
519519 constraints: action . constraints ,
520520 name: action . name ,
521+ description: nil ,
521522 from_generic_action?: true
522523 }
523524 end )
Original file line number Diff line number Diff line change @@ -200,6 +200,24 @@ defmodule AshGraphql.GenericActionsTest do
200200 end
201201 end
202202
203+ test "generic action returning an array of union NewType generates valid schema" do
204+ resp =
205+ """
206+ query {
207+ searchUnions {
208+ ... on GenericActionUnionStringResult {
209+ value
210+ }
211+ }
212+ }
213+ """
214+ |> Absinthe . run ( AshGraphql.Test.Schema )
215+
216+ assert { :ok , result } = resp
217+ refute Map . has_key? ( result , :errors )
218+ assert % { data: % { "searchUnions" => [ ] } } = result
219+ end
220+
203221 describe "generic action with require_actor? domain" do
204222 test "succeeds when actor is provided via GraphQL context" do
205223 resp =
Original file line number Diff line number Diff line change @@ -53,6 +53,30 @@ defmodule AshGraphql.Test.ResourceWithUnion do
5353 def graphql_input_type ( _ ) , do: :uniontype_input
5454 end
5555
56+ defmodule GenericActionUnion do
57+ @ moduledoc false
58+
59+ use Ash.Type.NewType ,
60+ subtype_of: :union ,
61+ constraints: [
62+ types: [
63+ string_result: [
64+ type: :string ,
65+ tag: :type ,
66+ tag_value: "string_result"
67+ ] ,
68+ integer_result: [
69+ type: :integer ,
70+ tag: :type ,
71+ tag_value: "integer_result"
72+ ]
73+ ]
74+ ]
75+
76+ def graphql_type ( _ ) , do: :generic_action_union
77+ def graphql_input_type ( _ ) , do: :generic_action_union_input
78+ end
79+
5680 use Ash.Resource ,
5781 domain: AshGraphql.Test.Domain ,
5882 data_layer: Ash.DataLayer.Ets ,
@@ -62,6 +86,7 @@ defmodule AshGraphql.Test.ResourceWithUnion do
6286 type ( :resource_with_union )
6387
6488 queries do
89+ action ( :search_unions , :search_unions )
6590 end
6691
6792 mutations do
@@ -72,6 +97,12 @@ defmodule AshGraphql.Test.ResourceWithUnion do
7297 actions do
7398 default_accept ( :* )
7499
100+ action :search_unions , { :array , GenericActionUnion } do
101+ run ( fn _input , _ctx ->
102+ { :ok , [ ] }
103+ end )
104+ end
105+
75106 action :action_with_union_arg , :boolean do
76107 argument ( :union_arg , Union , allow_nil?: false )
77108
You can’t perform that action at this time.
0 commit comments