Passing arguments when calling a Resource.Action via Ash.Query (Solved)

Hi!

Can’t wrap my head around passing arguments to an Action when it is invoke via Ash.Query.

I have some dynamic Generic Actions for specific table column names.

So before When I was doing.

MyApp.MyApi.Resource.get_distinct_values(%{column_name: "test"})

And due to mulitenancy and having to use set_tenant now it is more like

MyApp.MyApi.Resource
|> Ash.Query.for_read(:get_distinct_values)
|> Ash.Query.set_tenant("tenant1")
|> MyApp.MyApi.read!()

How do I pass argument to the action when using this form?

Thank you bunch!

Answering my own question:

By passing it in the for_read argument
https://hexdocs.pm/ash/Ash.Query.html#for_read/4

2 Likes

Welcome @CYMKD. Glad you found the answer :slight_smile:

1 Like