Here is variant where you get query in the end still
user_projects_query =
from(
relationship in UserProject,
join: p in Project,
on: relationship.project_id == p.id,
where: relationship.user_id == ^current_user.id,
where: ilike(p.name, ^"%#{substring}%"),
select: p
)