I want to use Ash as the backend and Inertia.js as web ui. has anyone done this before? Any suggestions are welcome.
Cheers,
Zhen Zhang
I want to use Ash as the backend and Inertia.js as web ui. has anyone done this before? Any suggestions are welcome.
Cheers,
Zhen Zhang
Looking through the Phoenix docs it seems like what all you’d do differently is call into Ash instead of Ecto, and would need an adapter for representing errors. Not sure if they have a behavior or protocol you can implement, but it would be pretty easy to write something if they do.
inertia-phoenix doesn’t have such a behavior or protocol. assign_errors() calls compile_errors!() which converts the changeset errors into a shape inertia recognizes.
BTW, they require that schemas be serialized to json via @derive Jason.Encoder. what does Ash do for this?
Ash does not define a JSON serializer like that automatically, primarily because it doesn’t really make a lot of sense to do given that different things can be loaded in different cases etc. However, if you must go that approach, you can derive a serializer if you like or use a tool like ash_json to derive one for you.
It is problematic that Inertia-phoenix integrates directly with Ecto in my opinion instead of providing behaviors that would let it work with anything. Likely integrating Ash with intertia-phoenix would necessitate making improvements to inertia-phoenix.
Wish I had a better answer for you Ultimately, this is the fundamental flaw that arises when libraries use
Ecto.Schema
as the integration point, instead of defining a behavior or protocol and making an Ecto.Schema
implementation for it.