Adding to the code interface of a domain in a fragment duplicates resource in Ash.Domain.Info.resources

When i have a Domain with a Resource, lets say Flora and Plant, i can add to the code interface of the Domain in a fragment by re-opening the resources block.

Like this:

resources do
  resource App.Flora.Plant do
    define :grow
  end
end

But calling Ash.Domain.Info.resources(App.Flora) now returns the resource twice.

[App.Flora.Plant, App.Flora.Plant]

Is there a way to make that work without this change up the output of the inspection tools?

1 Like

We can fix this, but is there a particular reason that you need to reopen the resource section?

I have a directory/namespace that contains as much of the code for a feature as possible. A supervisor, actions, etc, and I want to add the new actions to the domain’s code interface.

If here is a better way than adding the different files from my feature dir in the corresponding files in the ā€œcoreā€ app i’d be happy to hear about it.

I think I might need to see more code samples, I’m not quite following :smiley:

Sorry if i’m not clear enough. Pushed the code to github

Domain: XO/lib/xo/games.ex at main Ā· kioopi/XO Ā· GitHub

Resource: XO/lib/xo/games/game.ex at main Ā· kioopi/XO Ā· GitHub

The directory lib/xo/games/commentator/ contains code to add a LLM backed commentator for the game:

Fragment for Resource: XO/lib/xo/games/commentator/game_fragment.ex at main Ā· kioopi/XO Ā· GitHub

Fragment for Domain: XO/lib/xo/games/commentator/domain_fragment.ex at main Ā· kioopi/XO Ā· GitHub

Ah, sorry I totally misunderstood the fragment bit. That does seem like a problem. It’s not necessarily a bug but we can fix it by combining any duplicate resource declarations at compile time. Please open an issue!

Will do. Is that an Ash issue or rather for Spark?

An ash issue.