Query foreign table twice, once directly, once through join table

The docs https://supabase.com/docs/reference/javascript/select#query-foreign-tables-through-a-join-table almost get me there... But not quite. I need to query profiles.name for each player in a game. Not sure how to structure the select().

Here are the tables:
create table profiles (
  id uuid primary key references auth.users on delete cascade,
  name text,
  avatar_url text
);

create table games (
  id uuid primary key DEFAULT gen_random_uuid(),
  organizer_id uuid not null references profiles(id) on delete cascade,
  name text
);

create table players (
  id uuid primary key DEFAULT gen_random_uuid(),
  user_id uuid not null references profiles(id) on delete cascade,
  game_id uuid not null references games(id) on delete cascade
);

I can get the organizer's name
const { data: game } = await supabaseClient
        .from('games')
        .select('*,profiles(name, avatar_url)')
        .eq('id', event.params.id)
        .single();

But how would I get the names of each player?
Supabase Documentation
Fetch data: select()
Was this page helpful?