Reputation: 759
I have three models that are similar to this
schema "Author" do
has_many :posts, Repo.Post
end
schema "Post" do
has_many :comments Repo.Post
belongs_to :author, Repo.Author
end
schema "Comment" do
belongs_to :post, Repo.Post
end
how do I create a field or method for Author to display all comments? Essentially a secondary join. I need to be able to expose this to an Absinthe schema somehow.
Upvotes: 0
Views: 97
Reputation: 4885
schema "Author" do
has_many :posts, Repo.Post
has_many :comments, through: [:posts, :comments]
end
Upvotes: 1