ash
ash copied to clipboard
Allow to read applying another non-read policy
Problem
Sometimes, we want to read data applying another non-read policy, e.g. to read posts updatable by an actor.
For now, we have to create a special read action (e.g. :read_updatable) and copy the policy of the corresponding action (e.g. of the :update here).
Solution
This could be solved by adding a policy option to the reads function (Api.read, Api.exists?, Api.sum, etc.) to apply a specific policy.
And using it like:
MyResource
|> Api.read!(actor: actor, policy: :update)
Alternative
Won't do, to complicate to propagate a different non-read policy and suggest the workaround above.
When we add bulk destroys this will likely be implementable as a modification of that.