I have a change that is configured in the changes block like this:
changes do
change {Core.Ash.Changes.Audit, meta: %{actor: actor(:id)}},
on: [:create, :update, :destroy]
end
Here is that change implementation:
defmodule Core.Ash.Changes.Audit do
@moduledoc """
This change will use `Carbonite` to create a audit of a specific action
"""
use Ash.Resource.Change
@impl true
def change(changeset, opts, _) do
type = Keyword.get(opts, :type, to_string(changeset.action.name))
meta = Keyword.get(opts, :meta, %{})
meta = Map.put(meta, :type, type)
Ash.Changeset.around_action(changeset, fn changeset, callback ->
{:ok, _} = Carbonite.insert_transaction(Core.Repo, %{meta: meta})
callback.(changeset)
end)
end
end
And I also have this action in the same resource:
update :withdraw_offer do
require_atomic? false
accept []
change set_attribute(:status, :withdrawn)
end
If I call that action directly, the Core.Ash.Changes.Audit
is called correctly.
If I call that action using ash_graphql, it will not call that change at all. It does call the change/3 function but the function inside the around_action
function is never called.