ash icon indicating copy to clipboard operation
ash copied to clipboard

Support Through Relationships

Open andrewcallahan opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. We should be able to do all types of through relationships. We currently support many_to_many relationships with a through option, but we eventually want to support arbitrary through relationships.

Describe the solution you'd like Not sure how it will work, but I'd guess it would be similar to Ecto

Describe alternatives you've considered N/A

Express the feature either with a change to resource syntax, or with a change to the resource interface

has_many :teachers, MyApp.Teacher, through: [:classrooms, :teachers]

Additional context N/A

andrewcallahan avatar Jun 16 '20 03:06 andrewcallahan

I've had a thought on this, and I think that as long as these relationships are "read only" that it may actually be quite easy to work these out. They only really come into play for side loading. The other limitation may be that we may not be able to use them in ash policy authorizer

zachdaniel avatar Oct 15 '20 04:10 zachdaniel

Currently there are "custom relationships", and "aggregates" to support some of these use cases. However, they aren't as fluid as the option to simply say things like has_one :organization, Org, through: [:user, :owner]. This would be a great "medium sized" contribution if anyone is interested in working on it!

zachdaniel avatar Apr 05 '22 16:04 zachdaniel