I was using Ash_Authentication and switched to Guardian.
So when I ran the method, I found the following error.
I think it’s an error in the part where the router puts the context, but I don’t know why.
resource.ex
update :increment_dental_lab_post_view_count do
require_atomic? false
accept []
change atomic_update(:count_of_view, expr(count_of_view + 1))
end
router.ex
...
pipeline :api_with_auth do
plug :accepts, ["json"]
plug DentallogWeb.Auth.JwtPipeline
plug :_set_actor
plug AshGraphql.Plug
end
...
defp _set_actor(conn, _opts) do
case DentallogWeb.Auth.Guardian.Plug.current_resource(conn) do
{:ok, user} -> set_actor(conn, user)
nil -> conn
end
end
jwt_pipeline.ex
defmodule DentallogWeb.Auth.JwtPipeline do
use Guardian.Plug.Pipeline,
otp_app: :dentallog,
module: DentallogWeb.Auth.Guardian,
error_handler: DentallogWeb.Errors.GuardianErrorHandler
plug Guardian.Plug.VerifySession
plug Guardian.Plug.VerifyHeader
plug Guardian.Plug.EnsureAuthenticated
plug Guardian.Plug.LoadResource
end
[error] e7be1636-352e-42cd-b754-4058e247c7fa: Exception raised while resolving query.
** (FunctionClauseError) no function clause matching in Ash.Actions.Helpers.set_context/2
(ash 3.0.16) lib/ash/actions/helpers.ex:55: Ash.Actions.Helpers.set_context({:error, "Cannot perform a changeset with after action hooks atomically"}, %{})
(ash 3.0.16) lib/ash/actions/helpers.ex:66: Ash.Actions.Helpers.set_context_and_get_opts/3
(ash 3.0.16) lib/ash/actions/update/bulk.ex:151: Ash.Actions.Update.Bulk.run/6
(ash_graphql 1.2.0) lib/graphql/resolver.ex:1236: AshGraphql.Graphql.Resolver.mutate/2
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:234: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:189: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:174: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:145: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:67: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
(absinthe 1.7.7) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
(absinthe 1.7.7) lib/absinthe/pipeline.ex:408: Absinthe.Pipeline.run_phase/3
(absinthe_plug 1.5.8) lib/absinthe/plug.ex:536: Absinthe.Plug.run_query/4
(absinthe_plug 1.5.8) lib/absinthe/plug.ex:290: Absinthe.Plug.call/2
(phoenix 1.7.14) lib/phoenix/router/route.ex:42: Phoenix.Router.Route.call/2
(phoenix 1.7.14) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(dentallog 0.1.0) lib/dentallog_web/endpoint.ex:1: DentallogWeb.Endpoint.plug_builder_call/2
(dentallog 0.1.0) deps/plug/lib/plug/debugger.ex:136: DentallogWeb.Endpoint."call (overridable 3)"/2
(dentallog 0.1.0) lib/dentallog_web/endpoint.ex:1: DentallogWeb.Endpoint.call/2
(phoenix 1.7.14) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4