I have teams and each team has users, so there is a join table to link users to teams as its a many to many relation, here is my models:
defmodule App.Team do
You need to preload the :user as well as the :team_users:
:user
:team_users
teams_users = from(t in Team, where: t.owner_id == ^user_id) |> Repo.all() |> Repo.preload(team_users: :user)
There is a section on nested associations in the docs. https://hexdocs.pm/ecto/Ecto.Query.html#preload/3