ash-project / ash

A declarative, extensible framework for building Elixir applications.
https://www.ash-hq.org
MIT License
1.63k stars 219 forks source link

ash.gen.resource warning can not add to resource list #1595

Open flip111 opened 2 weeks ago

flip111 commented 2 weeks ago

I'm a total noobie to ash and phoenix. I'm getting a bit stuck on a point where i think the user experience could be a bit better.

I ran mix igniter.new fitness --install ash,ash_sqlite,ash_phoenix --with phx.new --extend sqlite

After that i want to run

mix ash.gen.resource Fitness.Exercise \
  --attribute title:string:required \
  --attribute category:string:required \
  --attribute filename:string:required \
  --attribute upload_date:date \
  --attribute daily_quota:integer \
  --uuid-primary-key id \
  --relationship has_many:repetitions:FitnessAsh.Repetition \
  --default-actions read,create,update,destroy \
  --extend ash_sqlite \
  --timestamps

And i see

Igniter - Warnings:

* Domain Elixir.Fitness was not an `Ash.Domain`, so could not add `Fitness.Exercise` to its resource list.

It's not clear to me whether:

  1. I need to add it to the resource list myself
  2. I am not supposed to generate ash models in the existing domain. (I thought later this domain is phoenix-only)
  3. I need to create a new domain for ash first before continuing here
  4. It was not a good choice to generate a new project with --with phx.new for a new user and this is more for advanced users who know how to integrate ash with phoenix better
albinkc commented 1 week ago

Reasoning number 2 seems the most apt.

https://elixirforum.com/t/ash-gen-resource-fails-partially-if-resource-is-top-level/65535

flip111 commented 1 week ago

@albinkc thanks that seems to be the way to go

Is there any opportunity to improve UX here by putting the solution into the Ignitor warning or in another place so that it pops up in the terminal? Like this bit "so could not add Fitness.Exercise to its resource list" doesn't really seem like something you would want to do, does it?

zachdaniel commented 2 days ago

What I think we should actually do here is say "X existed but is not an Ash.Domain, should we add use Ash.Domain to the module?"