postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

Seems like the types for many to many relationships are not working in v2

Open mzalevski opened this issue 2 years ago • 2 comments

Consider following generated types:

export interface Database {
  public: {
    Tables: {
      users_skills: {
        Row: {
          user_id: string;
          skill_id: number;
        };
      };
      users: {
        Row: {
          id: string;
          created_at: string;
          name: string | null;
        };
      };
      skills: {
        Row: {
          id: number;
          created_at: string;
          name: string;
        };
      };
    };
  };
}

when I try to supabase.from("users").select("*,skills(*)") I get

{
    id: string;
    created_at: string;
    name: string | null;
} & {
    skills: unknown;
}

I tried some things from the postgrest docs but nothing is working. Am I doing something wrong or is this inference not ready yet?

mzalevski avatar Oct 16 '22 08:10 mzalevski

Hey there, typings for embedded tables is still a WIP, but we have a PR that allows you to override the return type.

soedirgo avatar Oct 18 '22 05:10 soedirgo

Thanks @soedirgo. I'll be waiting then :)

mzalevski avatar Oct 18 '22 07:10 mzalevski