Ash FrameworkAF
Ash Frameworkโ€ข7mo agoโ€ข
26 replies
Sienhopist

Argument in many to many filter

I have a 2 resources Client and Data in a many to many relationship through a join resource client_data. The join resource has 2 UUID columns for the clients and data, but it also has a 3rd boolean column exposed?.

When reading clients through a read action, I want to provide an arg that says to load only the exposed related Data of a Client or the non exposed or both. So I've set an argument on the read action, but now how do I access it in the filter expr on the many to many relationship?
Solution
prepare fn query, _ ->
  case query.arguments[:visibility] do
    :exposed -> Ash.Query.load(query, data: Ash.Query.filter(Data, parent(client_data.exposed?)))
  end
end
Was this page helpful?