Change not called with update action is called from ash_graphql

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.

yep we need to prevent atomic upgrade if there are around action hooks.

actually, this is something else. will let you know soon.

okay, found it, fixed in main. please try it out, will cut a release today or tomorrow :slight_smile:

1 Like

Thanks! It is working now