Skip to content

Commit a31de26

Browse files
committed
fix: properly unwrap constraints & type for list newtypes
1 parent 3988820 commit a31de26

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/ash_graphql.ex

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,12 +944,21 @@ defmodule AshGraphql do
944944
attributes
945945
|> Enum.filter(&AshGraphql.Resource.define_type?(&1.type, &1.constraints))
946946
|> Enum.flat_map(fn attribute ->
947+
{type, constraints} =
948+
case attribute.type do
949+
{:array, type} ->
950+
{type, attribute.constraints[:items] || []}
951+
952+
type ->
953+
{type, attribute.constraints}
954+
end
955+
947956
attribute = %{
948-
type:
949-
attribute.type
950-
|> unwrap_type()
951-
|> Ash.Type.NewType.subtype_of(),
952-
constraints: Ash.Type.NewType.constraints(attribute.type, attribute.constraints)
957+
attribute
958+
| type:
959+
type
960+
|> Ash.Type.NewType.subtype_of(),
961+
constraints: Ash.Type.NewType.constraints(type, constraints)
953962
}
954963

955964
case unwrap_type(attribute.type) do

0 commit comments

Comments
 (0)