How do cleanly do action accepts for resources with a lot of attributes without `:*`?

With :* being deprecated in the future major version of Ash. Will you have to put all attributes in the accepts for the actions need to support all attributes? The answer very well may be you just have to list all the attributes in the action. But wanted to check.
Solution:
default_accept in the top level actions block
Jump to solution
9 Replies
sevenseacat
sevenseacat4mo ago
yep, listing all the attributes
ZachDaniel
ZachDaniel4mo ago
There are other options too
Solution
ZachDaniel
ZachDaniel4mo ago
default_accept in the top level actions block
ZachDaniel
ZachDaniel4mo ago
And @accepted [...] at the top of the module But if it's a lot of attributes and just a couple actions, explicit lists is simplest and least error prone
sevenseacat
sevenseacat4mo ago
@accepted is new to me - that isn't listed here https://hexdocs.pm/ash/actions.html#accepting-inputs
Chaz Watkins
Chaz WatkinsOP4mo ago
ok. The full lists will typically only be on primary :create or :update, so that seems reasonable. It'll just be a big change from doing :*. But I don't like putting all my attrs as public?: true just to use :* since it's going to be deprecated in the future. Thanks for the info.
sevenseacat
sevenseacat4mo ago
especially because public? true has other impacts as well, like making things accessible via APIs if you have them set up they're meant for actual public attributes, not as a shortcut for making them settable in actions
Chaz Watkins
Chaz WatkinsOP4mo ago
Submitted a PR to add this to the accept-inputs docs.
sevenseacat
sevenseacat4mo ago
ahhhhh I thought there was some secret special handling of a module attribute called @accepted or something

Did you find this page helpful?