supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
967 stars 130 forks source link

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

Open mzalevski opened 1 year ago

mzalevski commented 1 year ago

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?

soedirgo commented 1 year ago

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

mzalevski commented 1 year ago

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