Hey everyone, Im trying to use supabase with types...
# help
Hey everyone, Im trying to use supabase with typescript and I noticed that the
method doesn't support joined tables. Could someone help me out? I'll include details in the thread
Hello @nahtnam! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
Here is some sample code with the issue:
Copy code
const shape = getShape<definitions["posts"] & { unsplash_category_snapshots: definitions["profiles"]}>()({
  "*": true,
  users: {"_": "profile_id", "*": true}

await supabaseClient
  .from<typeof shape>("posts")
  .eq("profiles.email", "asdf@gmail.com")
The typescript errors on the
line saying that
is not a valid option
I think the
might need to be updated to use the template strings feature in typescript, but I'm not sure. Does anyone have any workarounds other than
// @ts-ignore
Not great with typescript, and your .select is a function, but to use a foreign table in a filter you need https://supabase.com/docs/reference/javascript/select#filtering-with-inner-joins. Also, as it is hard for me to read your code, is user a table versus users and is it a public schema table and not the auth.users table?
Oops that was a typo, it shouldve been
(these arent my table names, I just changed them to make it easier to understand)
Crap, i forgot that supabase has a
schema, let me rename it to
so it makes more sense 🙂
And to clarify, the code above works perfectly, its just the types fail. In the
it expects the first parameter to be a column of the
table, I couldnt figure out a way to have it accept
which is valid postgrest but fails ts
Alright here is a "temp" solution
.from<typeof shape & {"profiles.email": string}>("posts")
Thread was archived by @nahtnam. Anyone can send a message to unarchive it.