Action optional parameters for nested changes

Hi everyone!

I need a guidance for using context or action inputs or something like that.

I defined a function that calls an action.

define :delete_and_disconnect_integrations,
  action: :delete_and_disconnect_integrations

And two actions in different resources. One uses another one

destroy :delete_and_disconnect_integrations do
  soft? true
  require_atomic? false
  change set_attribute(:deleted_at, &DateTime.utc_now/0)
  change cascade_update(:token, action: :clear_and_disconnect)
  change Project.Context.Changes.Disconnect1
end
update :clear_and_disconnect do
  require_atomic? false
  change set_attribute(:token, nil)
  change Project.Context.Changes.Disconnect2
end

It updates two tables using cascade_update but also it calls an extenral API request for every table record. In case if the token is invalid I don’t need to call to an external API and I need to just update the db. I was considering adding a parameter to skip API calls like that:

Project.Context.delete_and_disconnect_integrations(
  struct.id,
  tenant: tenant.id,
  context: %{skip_api_calls: true}
)

And I can fetch it via Map.get(changeset.context, :skip_api_calls, false) in Disconnect1 but it isn’t available in Disconnect2.

How would you solve such problems in general?

The shared key was recently added for context that needs to be shared across action calls.

Before that, I might have solved this by using my own change that updates the child resource, allowing me to pass the options I want.

Thanks! It isn’t clear for me how to use shared in case I’m calling an action as a context function.

But I was also considering moving the whole logic to the parent change and I did it in that way eventually