ash
ash copied to clipboard
Support Through Relationships
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
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
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!