No read action exists for X when loading relationships

I’m getting an error of:

No read action exists for PointOfSale.Stores.ModifierGroup when: loading relationship modifier_groups

Product has a man_to_many relationship with ModifierGroup defined in each resource as follows:

defmodule PointOfSale.Stores.Product do

  relationships do
    many_to_many :modifier_groups, PointOfSale.Stores.ModifierGroup,
      through: PointOfSale.Stores.ProductModifierGroup
  end

and

  relationships do
    many_to_many :products, PointOfSale.Stores.Product,
      through: PointOfSale.Stores.ProductModifierGroup
  end

ProductModifierGroup is defined like this:

  relationships do
    belongs_to :product, PointOfSale.Stores.Product, primary_key?: true, allow_nil?: false

    belongs_to :modifier_group, PointOfSale.Stores.ModifierGroup, primary_key?: true, allow_nil?: false
  end

I get the error when trying to do this:

    Product.read_all!(tenant: tenant)
    |> Stores.load!(:modifier_groups)

I don’t get the same error when loading another many_to_many relationship on Product. I’m missing something somewhere, maybe it has to do with default reads? When loading a relationship what read action does Ash use?

1 Like

I figured it out. The intermediate join Resource ProductModifierGroup didn’t have any actions defined on it. The error though makes it seem like the action is missing on the target Resource.

1 Like