Ash FrameworkAF
Ash Framework8mo ago
7 replies
Ege

Read actions

I have this read action:
read :groups_by_organization_id do
  argument :organization_id, :uuid, allow_nil?: false

  filter expr(organization_id == ^arg(:organization_id))
  pagination offset?: true, countable: true, default_limit: 1000
end

Inside the filter expression, instead of the incoming organization_id, I want to use a different value that I derive from it:
decendant_orgs = get_descendant_organizations!([organization_id])
ids = [arg(:organization_id)] ++ Enum.map(descendant_orgs, org -> org.id end)

filter expr(organization_id == ^ids)

Is this possible?
Was this page helpful?