Hello I am trying to do a many to many association between resources from two diferent apis this is my registry from both sides
defmodule Hatamoto.Accounts.Registry do
alias Hatamoto.Accounts.{Client, ClientBranch, Company, Employee, Subscription, Token}
use Ash.Registry
entries do
entry Client
entry ClientBranch
entry Company
entry Employee
entry Subscription
entry Token
end
end
defmodule Hatamoto.Engine.Registry do
alias Hatamoto.Engine.{
Bill,
Branch,
Delivery,
Discount,
Notification,
Product,
Reminder,
Sale,
Stock,
Vehicle
}
use Ash.Registry
entries do
entry Bill
entry Branch
entry Delivery
entry Discount
entry Notification
entry Product
entry Reminder
entry Sale
entry Stock
entry Vehicle
end
end
This is my relationship on client module
many_to_many :branches, Hatamoto.Engine.Branch do
api Hatamoto.Engine
through Hatamoto.Accounts.ClientBranch
source_attribute_on_join_resource :client_id
destination_attribute_on_join_resource :branch_id
end
this is my relationship from branch
many_to_many :clients, Hatamoto.Accounts.Client do
api Hatamoto.Accounts
through Hatamoto.Accounts.ClientBranch
source_attribute_on_join_resource :branch_id
destination_attribute_on_join_resource :client_id
end
and this is my relationship from clientBranch resouse
relationships do
belongs_to :client, Hatamoto.Accounts.Client do
primary_key? true
allow_nil? false
end
belongs_to :branch, Hatamoto.Engine.Branch do
primary_key? true
allow_nil? false
end
end
But i got this error
Resource `Hatamoto.Accounts.ClientBranch` is not accepted by api `Hatamoto.Engine` for autogenerated join relationship: `:branches_join_assoc`
Relationship was generated by the `many_to_many` relationship `:branches`
If the `through` resource `Hatamoto.Accounts.ClientBranch` is not accepted by the same
api as the destination resource `Hatamoto.Engine.Branch`,
then you must define that relationship manually. To define it manually, add the following to your
relationships:
has_many :branches_join_assoc, Hatamoto.Accounts.ClientBranch do
# configure the relationship attributes
...
end
You can use a name other than `:branches_join_assoc`, but if you do, make sure to
add that to `:branches`, i.e
many_to_many :branches_join_assoc, Hatamoto.Accounts.ClientBranch do
...
join_relationship_name :your_new_name
end