The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
only show graphiql interface if graphql extension is enabled
Alaister Young327407484629
diff --git a/studio/pages/project/[ref]/graphiql/index.tsx b/studio/pages/project/[ref]/graphiql/index.tsxindex bbf6f911558..b7382665d15 100644--- a/studio/pages/project/[ref]/graphiql/index.tsx+++ b/studio/pages/project/[ref]/graphiql/index.tsx@@ -1,17 +1,31 @@+import { observer } from 'mobx-react-lite'import { createGraphiQLFetcher } from '@graphiql/toolkit'import { GraphiQL } from 'graphiql'import 'graphiql/graphiql.css'+import ExtensionCard from 'components/interfaces/Database/Extensions/ExtensionCard'import { ProjectLayoutWithAuth } from 'components/layouts'import Connecting from 'components/ui/Loading/Loading'-import { useParams, useProjectSettings } from 'hooks'+import { useParams, useProjectSettings, useStore } from 'hooks'import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'-import { useMemo } from 'react'+import { useEffect, useMemo } from 'react'import { NextPageWithLayout } from 'types'import { IconAlertCircle } from 'ui'const GraphiQLPage: NextPageWithLayout = () => {const { ref } = useParams()+ const { ui, meta } = useStore()++ const isExtensionsLoading = meta.extensions.isLoading+ const pgGraphqlExtension = meta.extensions.byId('pg_graphql')++ useEffect(() => {+ if (ui.selectedProject?.ref) {+ // Schemas may be needed when enabling the GraphQL extension+ meta.schemas.load()+ meta.extensions.load()+ }+ }, [ui.selectedProject?.ref])const {services,@@ -36,7 +50,7 @@ const GraphiQLPage: NextPageWithLayout = () => {})}, [graphqlUrl, anonKey])- if (isProjectSettingsLoading) {+ if (isProjectSettingsLoading || (isExtensionsLoading && !pgGraphqlExtension)) {return <Connecting />}@@ -49,6 +63,24 @@ const GraphiQLPage: NextPageWithLayout = () => {)}+ if (pgGraphqlExtension?.installed_version === null) {+ return (+ <div className="flex-1 flex flex-col justify-center items-center px-4">+ <div className="max-w-md w-full">+ <div className="mb-6">+ <h1 className="text-2xl mt-8 mb-2">Enable the GraphQL Extension</h1>+ <h2 className="text-scale-1100 text-sm">+ Toggle the switch below to enable the GraphQL extension. Then you can use the GraphQL+ API with your Supabase Database.+ </h2>+ </div>++ <ExtensionCard extension={pgGraphqlExtension} />+ </div>+ </div>+ )+ }+return <GraphiQL fetcher={fetcher} />}@@ -56,4 +88,4 @@ GraphiQLPage.getLayout = (page) => (<ProjectLayoutWithAuth title="GraphiQL">{page}</ProjectLayoutWithAuth>)-export default GraphiQLPage+export default observer(GraphiQLPage)