Actor not passed to `read` action after `create` action
I have a resource with a default
:create action and :read action, and an AshGraphql mutation that calls :create. The resource has a module-based policy that requires the actor have a certain "role". When I test the mutation, the policy allows the actor to perform the :create, but when it checks the :read action that happens at the end of the mutation, the actor passed to the policy is nil.
What makes this especially confusing is that I have other resources that are set up the same way, and they don't have this nil actor problem.
I'll post my code in the comments below.4 Replies
AFAIK we don't do a read action after the create action.
It could potentially be a request to load data, but that shouldn't rerun the policies on the resource, only on related resources that it has to read. And it should of course be setting the actor
When I debug that third
match? clause, the context contains a Ash.Resource.Actions.Read action for the GF.Announcements.Announcement2 resource.
Oh, wait
I found the problem. It's my test! It's calling the read action without an actor!
Wow, I spent a couple hours on this.
Thanks for being the rubber duck on this!Happy to help 🙂 This is a good ending for me, means no spelunking 😆
glad you got it worked out