Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing actor in context when calling a manual update action with an ash_graphql mutation #1217

Closed
miguel-s opened this issue Jun 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@miguel-s
Copy link

miguel-s commented Jun 1, 2024

Describe the bug

I think the actor gets lost when calling a manual update action with a ash_graphql mutation

To Reproduce

I have this action

update :update_recurring_this do
  accept [:amount, :date]
  argument :event_date, :date
  validate attribute_equals(:is_recurring, true)
  manual ManualUpdates.UpdateThis
  require_atomic? false
end

This code interface

define :update_recurring_transaction_this do
  action :update_recurring_this
  args [:event_date]
end

This graphql mutation

update :update_recurring_transaction_this, :update_recurring_this

The code interface works great and has the actor in the context of the manual update

%Ash.Resource.ManualUpdate.Context{
  actor: #User<...>,
  select: nil,
  tenant: nil,
  tracer: nil,
  authorize?: true,
  domain: Transactions,
  return_records?: nil,
  batch_size: nil
}

But when using the graphql mutation the actor is nil in the context of the manual update (I double checked that the auth is working correctly)

%Ash.Resource.ManualUpdate.Context{
  actor: nil,
  select: nil,
  tenant: nil,
  tracer: nil,
  authorize?: nil,
  domain: Transactions,
  return_records?: nil,
  batch_size: nil
}

Expected behavior

The context of the manual update action should have the actor set when called through a ash_graphql mutation

Runtime

  • Elixir version: 1.16.1
  • Erlang version: 26
  • OS: MacOS 14.4
  • Ash version: 3.0.9
  • any related extension versions: ash_graphql version: 1.1.0

Additional context

I checked the context in the manual action with a before_action change and the actor is set.

change before_action(fn changeset, context ->
               IO.inspect(context, label: "before")
               changeset
             end)
@miguel-s miguel-s added bug Something isn't working needs review labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants