This works:
read :future_works do
argument :foo, :atom do
constraints one_of: [:a, :b, :c]
end
filter expr(
date >= now() and
if is_nil(^arg(:foo)) do true else ^arg(:foo) in allowed_foos end
)
end
This doesn’t work:
read :future_works do
argument :foo, :atom do
constraints one_of: [:a, :b, :c]
end
prepare fn query, _ctx ->
query
|> Ash.Query.filter(^arg(:foo) in allowed_foos) # gives an error and doesn't compile
|> Ash.Query.filter(Ash.Query.get_argument(query, :foo) in allowed_foos) # gives an error and doesn't compile
|> Ash.Query.filter(expr(arg(:foo) in allowed_foos)) # gives an error and doesn't compile
end
end
Whats the correct way to write this? My point is that I want to re-use this filter for multiple read actions.