I am trying to write an after_action in Ash, like this:
update :create_note do
accept []
change fn changeset, context ->
Ash.Changeset.after_action(changeset, fn changeset, user ->
note_attrs = %{
name: "note 1",
description: "Default note",
user: user
}
practice = Project.Api.Note
|> Ash.Changeset.for_create(:create, note_attrs)
|> Project.Api.create!(authorize?: context.authorize?)
{:ok, user}
end)
end
end
I am wondering specifically about this line:
Project.Api.create!(authorize?: context.authorize?)
Is there a better way to chain the ‘context’ arguments through? Like, if there was an actor, could I send that into “Project.Api.create” without having to explicitly do:
Project.Api.create!(authorize?: context.authorize?, actor: context.actor)