Support for code_interface in embedded resources

I’m upgrading Ash from 2 to 3. Before I had a create action with a code interface in my embedded resource like this:

defmodule Coupon do
  @moduledoc false

  use Ash.Resource,
    data_layer: :embedded

  code_interface do
    define :new
  end
  ...
  actions do
    create :new, primary?: true
  end
end

I expect that a function Coupon.new/1 will be created, but that doesn’t seem to be the case, did something changed regarding this from 2 to 3? I can’t find anything regarding this in the upgrade documentation.

Interesting…I honestly hadn’t even considered having a code interface on an embedded resource. You’ll need to set the domain option inside the code_interface block:

  code_interface do
    domain TheDomain.ToUse
    define :new
  end

If you don’t want to use an existing domain, you can do this:

defmodule EmbedDomain do
  use Ash.Domain

  resources do
    allow_unregistered? true
  end
end
1 Like