The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update based on https://github.com/supabase/infrastructure/pull/11896
Joshen Limb2ec7a6d3e93
diff --git a/studio/components/interfaces/GraphQL/GraphiQL.tsx b/studio/components/interfaces/GraphQL/GraphiQL.tsxindex 4780cf40d25..7613233809f 100644--- a/studio/components/interfaces/GraphQL/GraphiQL.tsx+++ b/studio/components/interfaces/GraphQL/GraphiQL.tsx@@ -44,10 +44,10 @@ import styles from './graphiql.module.css'export type GraphiQLProps = {fetcher: Fetchertheme?: 'dark' | 'light'- apiKey?: string+ accessToken?: string}-const GraphiQL = ({ fetcher, theme = 'dark', apiKey }: GraphiQLProps) => {+const GraphiQL = ({ fetcher, theme = 'dark', accessToken }: GraphiQLProps) => {// Ensure props are correctif (typeof fetcher !== 'function') {throw new TypeError(@@ -56,7 +56,10 @@ const GraphiQL = ({ fetcher, theme = 'dark', apiKey }: GraphiQLProps) => {}return (- <GraphiQLProvider fetcher={fetcher} defaultHeaders={JSON.stringify({ apiKey }, null, 2)}>+ <GraphiQLProvider+ fetcher={fetcher}+ defaultHeaders={JSON.stringify({ Authorization: `Bearer ${accessToken}` })}+ ><GraphiQLInterface theme={theme} /></GraphiQLProvider>)diff --git a/studio/pages/project/[ref]/api/graphiql.tsx b/studio/pages/project/[ref]/api/graphiql.tsxindex 8b449994aee..dce704f0b61 100644--- a/studio/pages/project/[ref]/api/graphiql.tsx+++ b/studio/pages/project/[ref]/api/graphiql.tsx@@ -1,19 +1,20 @@+import { useEffect, useMemo, useState } from 'react'import { observer } from 'mobx-react-lite'import { createGraphiQLFetcher } from '@graphiql/toolkit'+import { NextPageWithLayout } from 'types'+import { useParams, useStore } from 'hooks'+import { API_URL } from 'lib/constants'+import { getAccessToken } from 'lib/common/fetch'import ExtensionCard from 'components/interfaces/Database/Extensions/ExtensionCard'import GraphiQL from 'components/interfaces/GraphQL/GraphiQL'import { DocsLayout } from 'components/layouts'import Connecting from 'components/ui/Loading/Loading'-import { useParams, useStore } from 'hooks'-import { useProjectApiQuery } from 'data/config/project-api-query'-import { useEffect, useMemo } from 'react'-import { NextPageWithLayout } from 'types'-import { IconAlertCircle } from 'ui'const GraphiQLPage: NextPageWithLayout = () => {const { ref: projectRef } = useParams()const { ui, meta } = useStore()+ const [accessToken, setAccessToken] = useState<string>()const isExtensionsLoading = meta.extensions.isLoadingconst pgGraphqlExtension = meta.extensions.byId('pg_graphql')@@ -24,44 +25,24 @@ const GraphiQLPage: NextPageWithLayout = () => {meta.schemas.load()meta.extensions.load()}- }, [ui.selectedProject?.ref])-- const {- data: settings,- isError: isProjectSettingsError,- isLoading: isProjectSettingsLoading,- } = useProjectApiQuery({- projectRef,- })- const apiService = settings?.autoApiService- const anonKey = apiService?.service_api_keys.find((x) => x.name === 'anon key')- ? apiService.defaultApiKey- : undefined- const endpoint = settings?.autoApiService.app_config.endpoint ?? ''+ const fetchAccessToken = async () => {+ const accessToken = await getAccessToken()+ setAccessToken(accessToken)+ }+ fetchAccessToken()+ }, [ui.selectedProject?.ref])- const graphqlUrl = `https://${endpoint}/graphql/v1`+ const graphqlUrl = `${API_URL}/projects/${projectRef}/api/graphql`const fetcher = useMemo(() => {- return createGraphiQLFetcher({- url: graphqlUrl,- fetch,- })+ return createGraphiQLFetcher({ url: graphqlUrl, fetch })}, [graphqlUrl])- if (isProjectSettingsLoading || (isExtensionsLoading && !pgGraphqlExtension)) {+ if (!accessToken || (isExtensionsLoading && !pgGraphqlExtension)) {return <Connecting />}- if (isProjectSettingsError) {- return (- <div className="py-8 flex items-center justify-center space-x-2">- <IconAlertCircle size={16} strokeWidth={1.5} />- <p className="text-sm text-scale-1100">Failed to retrieve API keys</p>- </div>- )- }-if (pgGraphqlExtension?.installed_version === null) {return (<div className="flex-1 flex flex-col justify-center items-center px-4">@@ -80,7 +61,7 @@ const GraphiQLPage: NextPageWithLayout = () => {)}- return <GraphiQL fetcher={fetcher} theme={ui.theme} apiKey={anonKey} />+ return <GraphiQL fetcher={fetcher} theme={ui.theme} accessToken={accessToken} />}GraphiQLPage.getLayout = (page) => <DocsLayout title="GraphiQL">{page}</DocsLayout>