Should resources with relationships spanning multiple Ash APIs be included in all registries

Hi folks, I've introduced two Ash APIs (Accounts and Invoicing) with one resource each (MyApp.Accounts.User MyApp.Invoicing.Invoice), and one registry for each API, each with the corresponding resource. As I introduce the relationship where Invoice belongs_to User and the inverse User has_many Invoice, the ResourceValidations extension started to complain :
MyApp.Accounts.User must be included in the registry.
MyApp.Accounts.User must be included in the registry.
Should each resource appear in both registries? Thanks
2 Replies
ZachDaniel
ZachDaniel3y ago
Nope! You just need to specify the api option when creating cross-api relationships and then it won’t require that you put it in the registry.
axelb
axelbOP3y ago
Insane reactivity, thanks! This solved the error. For reference, the relationship ends up looking like this :
relationships do
belongs_to :user, MyApp.Accounts.User, api: MyApp.Accounts
end
relationships do
belongs_to :user, MyApp.Accounts.User, api: MyApp.Accounts
end

Did you find this page helpful?