supabase / postgrest-js

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

`rpc` not automatically typing response #430

Closed bombillazo closed 1 year ago

bombillazo commented 1 year ago

Bug report

Describe the bug

The supabase client is not automatically typing RPC functions all responses based on the generated Database type.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a DB function in your database
  2. Generate DB types with CLI
  3. Create a supabase client, type with generated Database type.
    export const supabase = createClient<Database>(
    env.SUPABASE_URL,
    env.SUPABASE_ANON_KEY,
    );
  4. Use the RPC function with the client.
    const response = await supabase.rpc('my_function', data);
  5. Response is untyped

Expected behavior

The supabase client automatically types the RPC response based on the Database schema types

Screenshots

image

Working if the types are explicitly passed:

image

System information

Additional context

Add any other context about the problem here.

soedirgo commented 1 year ago

Can you provide your CLI version & supabase-js/postgrest-js versions? We have a test for RPC return types so not sure how this happened.

bombillazo commented 1 year ago

i think this is solved, probably an intermediary cli version was fixed and now works. closing :)