Ash FrameworkAF
Ash Framework3y ago
10 replies
Blibs

Adding a embedded resource to a resource is failing

I have this embedded resource:

defmodule Marketplace.Markets.Property.Image do
  use Ash.Resource,
      data_layer: :embedded,
      extensions: [AshGraphql.Resource]

  code_interface do
    define_for Marketplace.Markets

    define :new
  end

  actions do
    create :new, primary?: true
  end

  attributes do
    attribute :uuid, :uuid, allow_nil?: false

    attribute :category, :atom do
      constraints one_of: [:bedroom, :bathroom]
    end

    attribute :description, :string
  end

  graphql do
    type :image
  end
end


I'm trying to use it inside another resource:

attribute :images, {:array, Marketplace.Markets.Property.Image}, default: []


But I'm getting the following error:

== Compilation error in file lib/marketplace/markets/property.ex ==
** (RuntimeError) {:array, Marketplace.Markets.Property.Image} 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
  :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
  :url_encoded_binary -> Ash.Type.UrlEncodedBinary
  :union -> Ash.Type.Union


    (ash 2.6.17) lib/ash/type/type.ex:928: Ash.Type.set_type_transformation/1
    lib/marketplace/markets/property.ex:163: (module)
Was this page helpful?