From 485880fb87437d0be39f32cc1e8dcd7f730ebe15 Mon Sep 17 00:00:00 2001 From: ph0t0shop Date: Tue, 30 Sep 2025 10:29:48 +0200 Subject: [PATCH 1/4] Update SupabaseClient#from function signatures to match PostgrestClient#from --- src/SupabaseClient.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/SupabaseClient.ts b/src/SupabaseClient.ts index 3acd10edf..f41c38b2b 100644 --- a/src/SupabaseClient.ts +++ b/src/SupabaseClient.ts @@ -4,6 +4,7 @@ import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder, + PostgrestQueryBuilderOptions, } from '@supabase/postgrest-js' import { RealtimeChannel, @@ -182,17 +183,24 @@ export default class SupabaseClient< from< TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName] - >(relation: TableName): PostgrestQueryBuilder + >( + relation: TableName, + options?: PostgrestQueryBuilderOptions + ): PostgrestQueryBuilder from( - relation: ViewName + relation: ViewName, + options?: PostgrestQueryBuilderOptions ): PostgrestQueryBuilder /** * Perform a query on a table or a view. * * @param relation - The table or view name to query */ - from(relation: string): PostgrestQueryBuilder { - return this.rest.from(relation) + from( + relation: string, + options?: PostgrestQueryBuilderOptions + ): PostgrestQueryBuilder { + return this.rest.from(relation, options) } // NOTE: signatures must be kept in sync with PostgrestClient.schema From fe0637d24c0a98a8a20fecaddd20681e26cfa4bf Mon Sep 17 00:00:00 2001 From: ph0t0shop Date: Tue, 30 Sep 2025 10:41:25 +0200 Subject: [PATCH 2/4] Fix types --- src/SupabaseClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SupabaseClient.ts b/src/SupabaseClient.ts index f41c38b2b..52427fdeb 100644 --- a/src/SupabaseClient.ts +++ b/src/SupabaseClient.ts @@ -4,8 +4,8 @@ import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder, - PostgrestQueryBuilderOptions, } from '@supabase/postgrest-js' +import type { PostgrestQueryBuilderOptions } from '@supabase/postgrest-js' import { RealtimeChannel, RealtimeChannelOptions, From 14825b261025c5a901971f4c629ef681baf1e8a7 Mon Sep 17 00:00:00 2001 From: ph0t0shop Date: Tue, 30 Sep 2025 10:41:50 +0200 Subject: [PATCH 3/4] Fix import --- src/SupabaseClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SupabaseClient.ts b/src/SupabaseClient.ts index 52427fdeb..f41c38b2b 100644 --- a/src/SupabaseClient.ts +++ b/src/SupabaseClient.ts @@ -4,8 +4,8 @@ import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder, + PostgrestQueryBuilderOptions, } from '@supabase/postgrest-js' -import type { PostgrestQueryBuilderOptions } from '@supabase/postgrest-js' import { RealtimeChannel, RealtimeChannelOptions, From 14bc550d58aac9f159ea5ef478cc8d000b8ea73b Mon Sep 17 00:00:00 2001 From: ph0t0shop Date: Tue, 30 Sep 2025 12:09:46 +0200 Subject: [PATCH 4/4] Add credentials to custom fetch implementation --- src/SupabaseClient.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SupabaseClient.ts b/src/SupabaseClient.ts index f41c38b2b..9877bf334 100644 --- a/src/SupabaseClient.ts +++ b/src/SupabaseClient.ts @@ -145,7 +145,7 @@ export default class SupabaseClient< }) } - this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch) + this.fetch = this._createFetchWithAuth(settings.global.fetch) this.realtime = this._initRealtimeClient({ headers: this.headers, accessToken: this._getAccessToken.bind(this), @@ -200,6 +200,10 @@ export default class SupabaseClient< relation: string, options?: PostgrestQueryBuilderOptions ): PostgrestQueryBuilder { + if (options?.fetch) { + options.fetch = this._createFetchWithAuth(options.fetch) + } + return this.rest.from(relation, options) } @@ -386,4 +390,8 @@ export default class SupabaseClient< this.changedAccessToken = undefined } } + + private _createFetchWithAuth(_fetch?: typeof global.fetch) { + return fetchWithAuth(this.supabaseKey, this._getAccessToken.bind(this), _fetch) + } }