@@ -2852,16 +2852,14 @@ defmodule AshGraphql.Graphql.Resolver do
28522852 )
28532853
28542854 result ->
2855- { type , constraints } =
2856- unwrap_type_and_constraints ( calculation . type , calculation . constraints )
2855+ unwrapped_type =
2856+ unwrap_type ( calculation . type )
28572857
28582858 result =
2859- if Ash.Type.NewType . new_type? ( type ) &&
2860- Ash.Type.NewType . subtype_of ( type ) == Ash.Type.Union &&
2861- function_exported? ( type , :graphql_unnested_unions , 1 ) do
2862- unnested_types = type . graphql_unnested_unions ( calculation . constraints )
2863-
2864- calculation = % { calculation | type: type , constraints: constraints }
2859+ if Ash.Type.NewType . new_type? ( unwrapped_type ) &&
2860+ Ash.Type.NewType . subtype_of ( unwrapped_type ) == Ash.Type.Union &&
2861+ function_exported? ( unwrapped_type , :graphql_unnested_unions , 1 ) do
2862+ unnested_types = unwrapped_type . graphql_unnested_unions ( calculation . constraints )
28652863
28662864 resolve_union_result (
28672865 result ,
@@ -2875,10 +2873,10 @@ defmodule AshGraphql.Graphql.Resolver do
28752873 end
28762874 end
28772875
2878- defp unwrap_type_and_constraints ( { :array , type } , constraints ) ,
2879- do: unwrap_type_and_constraints ( type , constraints [ :items ] || [ ] )
2876+ defp unwrap_type ( { :array , type } ) ,
2877+ do: unwrap_type ( type )
28802878
2881- defp unwrap_type_and_constraints ( other , constraints ) , do: { other , constraints }
2879+ defp unwrap_type ( other ) , do: other
28822880
28832881 def resolve_assoc_one ( % Absinthe.Resolution { state: :resolved } = resolution , _ ) ,
28842882 do: resolution
@@ -3032,31 +3030,17 @@ defmodule AshGraphql.Graphql.Resolver do
30323030 defp resolve_union_result (
30333031 value ,
30343032 { name , { :array , field_type } , field , resource , unnested_types , domain }
3035- )
3036- when is_list ( value ) do
3037- Enum . map (
3038- value ,
3039- & resolve_union_result (
3040- & 1 ,
3041- { name , field_type , % { field | constraints: field . constraints [ :items ] } , resource ,
3042- unnested_types , domain }
3043- )
3044- )
3045- end
3046-
3047- defp resolve_union_result (
3048- value ,
3049- { name , field_type , field , resource , unnested_types , domain }
3050- )
3051- when is_list ( value ) do
3052- Enum . map (
3053- value ,
3054- & resolve_union_result (
3055- & 1 ,
3056- { name , field_type , % { field | constraints: field . constraints } , resource , unnested_types ,
3057- domain }
3033+ ) do
3034+ if value do
3035+ Enum . map (
3036+ value ,
3037+ & resolve_union_result (
3038+ & 1 ,
3039+ { name , field_type , % { field | type: field_type , constraints: field . constraints [ :items ] } ,
3040+ resource , unnested_types , domain }
3041+ )
30583042 )
3059- )
3043+ end
30603044 end
30613045
30623046 defp resolve_union_result (
0 commit comments