Argument derived from struct for manage_relationship changes

When I want to add an manage_relationship change to a create/update action, all the examples I see use an argument for it with :map

update :something do
  argument :bla, :map

  change manage_relationship(:bla, type: :create, on_no_match: :create)
end

This works, but it makes create apis a little bit cumbersome since :bla can be a map with anything inside.

For example, using AshTypescript in the above action, will make :bla argument be any instead of a proper typed class.

I tried doing something like this:

update :something do
  argument :bla, :struct do
    constraints instance_of: Bla
  end

  change manage_relationship(:bla, type: :create, on_no_match: :create)
end

This will generate the correct type, but, it will fail because it will expect now that my :bla argument contains :id, :inserted_at and :updated__at

I’m wondering, is there a proper way to do this? I could keep it a map and add constraints for the keys, but that just means that every time I change Bla, I need to remember that there is this action that I need to update the input too.

Basically, what I think this should do is if I use the struct, it would filter the resource attribute for only its writable attributes and use this as the argument possible keys.

For example:

# This one contains :id, :inserted_at and :updated_at, so, it doesn't work
iex(4)> Bla |> Ash.Resource.Info.attributes() |> Enum.map(& &1.name)
[:id, :licenses, :units_sold_last_12_months, :amount_sold_last_12_months,
 :inserted_at, :updated_at, :user_id]

# This one filters not writable fields, so it should work
iex(3)> Bla |> Ash.Resource.Info.attributes() |> Enum.filter(& &1.writable?) |> Enum.map(& &1.name)
[:licenses, :units_sold_last_12_months, :amount_sold_last_12_months, :user_id]

This is actually something that we do in AshGraphql that we can port to AshTypescript. It is fairly complex, but a managed relationship can call multiple actions theoretically so building their input types is complex. I’d suggest opening an issue in AshTypescript and expressing the value and explaining that there is code in AshGraphql to use as a reference.

Do you know which file implements that in AshGraphql so I can reference it directly in the ticket?