Hey all I’m running into this when trying to use embeds with Ash, even though I’m following the docs from ash 3.0.0 found here: Embedded Resources — ash v3.0.0-rc.21
** (RuntimeError) {:array, WfdBase.Recipes.Ingredient} is not a valid type.
Valid types include any custom types, or the following short codes (alongside the types they map to):
:map -> Ash.Type.Map
:keyword -> Ash.Type.Keyword
:term -> Ash.Type.Term
:atom -> Ash.Type.Atom
:string -> Ash.Type.String
:integer -> Ash.Type.Integer
:float -> Ash.Type.Float
:duration_name -> Ash.Type.DurationName
:function -> Ash.Type.Function
:boolean -> Ash.Type.Boolean
:struct -> Ash.Type.Struct
:uuid -> Ash.Type.UUID
:binary -> Ash.Type.Binary
:date -> Ash.Type.Date
:time -> Ash.Type.Time
:decimal -> Ash.Type.Decimal
:ci_string -> Ash.Type.CiString
:naive_datetime -> Ash.Type.NaiveDatetime
:utc_datetime -> Ash.Type.UtcDatetime
:utc_datetime_usec -> Ash.Type.UtcDatetimeUsec
:datetime -> Ash.Type.DateTime
:url_encoded_binary -> Ash.Type.UrlEncodedBinary
:union -> Ash.Type.Union
:module -> Ash.Type.Module
:vector -> Ash.Type.Vector
My main resource is this:
defmodule WfdBase.Recipes.Recipe do
use Ash.Resource,
data_layer: AshPostgres.DataLayer,
domain: WfdBase.Recipes
postgres do
table "recipes"
repo WfdBase.Repo
end
attributes do
uuid_primary_key :id
attribute :title, :string, default: nil
attribute :preparation_step, :string, default: nil
attribute :preparation_time, :integer
attribute :kitchenware, {:array, :string}, default: []
attribute :utensils, {:array, :string}, default: []
attribute :diet_labels, {:array, :string}
attribute :dish_type, {:array, :string}
attribute :cuisine_type, {:array, :string}
attribute :cautions, {:array, :string}, default: []
attribute :yield, :integer
attribute :ingredients, {:array, WfdBase.Recipes.Ingredient}
attribute :instructions, {:array, WfdBase.Recipes.Instruction}
attribute :nutritional_content, {:array, WfdBase.Recipes.Nutrient}
end
actions do
defaults [:read]
create :create do
accept [
:title,
:preparation_step,
:preparation_time,
:kitchenware,
:utensils,
:diet_labels,
:dish_type,
:cuisine_type,
:cautions,
:yield,
:ingredients,
:instructions,
:nutritional_content
]
end
end
end
And the embeded schemas I’m using are the following:
defmodule WfdBase.Recipes.Ingredient do
use Ash.Resource,
data_layer: :embedded,
embed_nil_values?: false
attributes do
attribute :name, :string, public?: true
attribute :unit, :string, public?: true
attribute :amount, :string, public?: true
end
end
defmodule WfdBase.Recipes.Instruction do
use Ash.Resource,
data_layer: :embedded,
embed_nil_values?: false
attributes do
attribute :position, :integer, public?: true
attribute :description, :string, public?: true
end
end
defmodule WfdBase.Recipes.Nutrient do
use Ash.Resource,
data_layer: :embedded,
embed_nil_values?: false
attributes do
attribute :name, :string, public?: true
attribute :unit, :string, public?: true
attribute :amount, :integer, public?: true
end
end
Maybe I’m missing something very evident, but would really appreciate some input
Thanks in advance!
Camille