Can I embed Ecto Changesets in an Ash Resource?

I have a library that provides a couple of Ecto Changesets.

Unfortunately, those Changesets are out of my control.

In my project, I would like to use Ash Resources instead of plain Ecto.Changesets.

Some of my Ash Resources need to embed the given Ecto Changesets.

However, when defining attributes, I can only reference anything that implements Ash.Type from what I can tell.

Is it possible to embed “plain” Ecto Changesets in an Ash resource?

Not really, no. You can write manual/custom actions that call into whatever code you want, and you can construct ecto change sets for an Ash resource, but they won’t play together, i.e you’re either entirely using an Ash.Changeset or an Ecto.Changeset. (unless you’re writing a manual action, then you have an Ash.Changeset that runs your manual action, then you can write some ecto code).

1 Like