How to compose read actions?

I have a read action with a small prepare that selects a few attributes and filters. I want to make a new read action that uses the same query as the previous read action, but also loads a calculation and a few relationships. How do I "compose" this with the old read action?
Solution:
You don't compose them together, you share a preparation between the two actions
Jump to solution
2 Replies
Rebecca Le
Rebecca Le3mo ago
You can build on read actions in code, eg.
Ash.Query.for_read(YourResource, :custom_read)
|> Ash.Query.load([more, loads, here])
|> Ash.read()
Ash.Query.for_read(YourResource, :custom_read)
|> Ash.Query.load([more, loads, here])
|> Ash.read()
but I don't think you can do it at the action level
Solution
ZachDaniel
ZachDaniel3mo ago
You don't compose them together, you share a preparation between the two actions

Did you find this page helpful?