The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: Refactor the foreign tables query to use FE pg-meta (#41077)
Ivan Vasilov26b469894d5f
diff --git a/apps/studio/data/foreign-tables/foreign-tables-query.ts b/apps/studio/data/foreign-tables/foreign-tables-query.tsindex 5de130a2904..c657b2ae2dd 100644--- a/apps/studio/data/foreign-tables/foreign-tables-query.ts+++ b/apps/studio/data/foreign-tables/foreign-tables-query.ts@@ -1,8 +1,8 @@+import pgMeta from '@supabase/pg-meta'+import { PostgresView } from '@supabase/postgres-meta'import { useQuery } from '@tanstack/react-query'-import { DEFAULT_PLATFORM_APPLICATION_NAME } from '@supabase/pg-meta/src/constants'-import { PostgresView } from '@supabase/postgres-meta'-import { get, handleError } from 'data/fetchers'+import { executeSql } from 'data/sql/execute-sql-query'import type { ResponseError, UseCustomQueryOptions } from 'types'import { foreignTableKeys } from './keys'@@ -16,29 +16,17 @@ export async function getForeignTables({ projectRef, connectionString, schema }: ForeignTablesVariables,signal?: AbortSignal) {- if (!projectRef) throw new Error('projectRef is required')-- let headers = new Headers()- if (connectionString) headers.set('x-connection-encrypted', connectionString)-- const { data, error } = await get('/platform/pg-meta/{ref}/foreign-tables', {- params: {- header: {- 'x-connection-encrypted': connectionString!,- 'x-pg-application-name': DEFAULT_PLATFORM_APPLICATION_NAME,- },- path: { ref: projectRef },- query: {- included_schemas: schema || '',- include_columns: true,- } as any,+ const { result } = await executeSql(+ {+ projectRef,+ connectionString,+ sql: pgMeta.foreignTables.list(schema ? { includedSchemas: [schema] } : undefined).sql,+ queryKey: ['foreign-tables', schema],},- headers,- signal,- })+ signal+ )- if (error) handleError(error)- return data as PostgresView[]+ return result as PostgresView[]}export type ForeignTablesData = Awaited<ReturnType<typeof getForeignTables>>