"Basic" actions
zachdaniel:
Initial support (still experimental) for basic actions has been pushed to main. A basic action is essentially just a function, but with some of the benefits of standard Ash actions. You specify input arguments and the return type. This will eventually be supported by the api extensions as well.
action :hello, :string do
argument :name, :string, allow_nil?: false
run(fn input, _context ->
{:ok, "Hello #{input.arguments.name}"}
end)
end
The benefit of using basic actions instead of defining normal functions:
- They can be used with api extensions
- They support Ash authorization patterns (i.e policies)
- They can be included in the code interface of a resource
-
They can be made transactional with a single option (
transaction? true
)
zachdaniel:
api extension support coming at some unknown point in the future. PRs welcome 😄
jharton:
This is absolutely awesome my dude.
Eduardo B. Alexandre:
This is amazing, exactly what I needed to integrate with FunWithFlags, thanks!
\ ឵឵឵:
If you’re still searching for a name for these things: generic actions
zachdaniel:
yep, thats better 🙂
zachdaniel:
Changing that in the docs