I know that it is possible to use plain ecto queries to query an Ash resource.
But is it also possible to use Repo.preload
function? When I try to use it it fails because, of course, it doesn’t recognizes the Ash.NotLoaded
module.
I know that it is possible to use plain ecto queries to query an Ash resource.
But is it also possible to use Repo.preload
function? When I try to use it it fails because, of course, it doesn’t recognizes the Ash.NotLoaded
module.
I’m not sure. There are some helper functions in the repo for turning records to/from ash/ecto IIRC, you could fetch your records and use that. Kind of a bummer if not, but it makes sense. You can probably use an option to preload to prevent it from ignoring fields that are already loaded.
I ran into this today trying to use Bling on an ash project.
Unfortunately, I don’t think that there is much that we can do about this at this point.
I think I found a way to work around this for my specific use case with Bling by providing it a proxy Repo which is implemented by calling ash functions.
You should totally document this somewhere because you will likely not be the only person who will struggle with this.
uhmm, i’m pretty sure the main question here is how to preload ash relationships, not to use Ecto stuff specifically (Although that library example is probably that case).
in which case the docs here would help: Ash Framework
Ash.load(user, :tweets)
The question here was about how to use Ecto.preload
with Ash resources directly. Ash resources are also ecto schemas and support being used in many ways as if they were just ecto schemas, but Repo.preload
doesn’t know about our %Ash.NotLoaded{}
struct.