How add sub key on query

Okay I have this query :
const {
    data: playlist,
    refetch,
  } = useQuery({
    queryKey: playlistKeys.detail(Number(params.playlist)),
    queryFn: async () => {
      if (!params.playlist || !params.lang) throw new Error('No playlist id or locale');
      const { data } = await supabase
        .from('playlist')
        .select(`
          *,
          user(*),
          items:playlist_item(
            *,
            movie(*)
          ),
          guests:playlist_guest(
            *,
            user:user(*)
          )
        `)
        .eq('id', params.playlist)
        .order('rank', { ascending: true, referencedTable: 'playlist_item' })
        .returns<Playlist[]>()
        .single();
      return data;
    },
    enabled: !!params.playlist && !!params.lang,
  });

Basically the key of this query is ['playlist', id]. My question is how to add sub key for
items
and guests like this :
['playlist', id, 'items']
['playlist', id, 'guests']

What is the best way to do it ? Thx !
Was this page helpful?