ash-project / ash_graphql

The extension for building GraphQL APIs with Ash
https://hexdocs.pm/ash_graphql
MIT License
71 stars 46 forks source link

The mutation/custom read action fails in simple data layer resource #169

Closed jichon closed 3 months ago

jichon commented 3 months ago

Describe the bug

After upgrading to the ash v3 and ash_graphql v1.1, update mutation with read_action is having an issue in our simple data layer resource

actions do
  default [:read, :update]

  read :read_post do
    ...
  end

  update :update_post do
    ...
  end
end

mutations do
  update :update_post, :update_post, read_action: :read_post, identity: false
end

It always defaults to the primary action even though it's specified to use the custom read action. If the custom read action is set to primary then it works. Here is the error message.

11:29:51.300 [error] a55f43fb-2809-4315-bd89-30a1382d2636: Exception raised while resolving query.

** (Ash.Error.Framework) Framework Error

* No data provided to resource Elixir.SomePackage.Post. Perhaps you are missing a call to `Ash.DataLayer.Simple.set_data/2`?.

Another common cause of this is failing to add a data layer for a resource. You can add a data layer like so:

`use Ash.Resource, data_layer: Ash.DataLayer.Ets`

To Reproduce

I've created a test for this in my forked repo

https://github.com/jichon/ash_graphql

jichon commented 3 months ago

I forgot to mention. I've added the test to update_test.ex

zachdaniel commented 3 months ago

Fix released in 1.1.1