Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

move graphiql to react-query

Alaister Young958559b2f78c
diff --git a/studio/package.json b/studio/package.json
index 15a7c89b7fd..ffa23069e4d 100644
--- a/studio/package.json
+++ b/studio/package.json
@@ -44,7 +44,7 @@
"dayjs": "^1.11.0",
"file-saver": "^2.0.5",
"generate-password": "^1.7.0",
- "graphiql": "^2.0.13",
+ "graphiql": "^2.2.0",
"graphql": "^16.6.0",
"html-to-image": "^1.10.8",
"immutability-helper": "^3.1.1",
diff --git a/studio/pages/project/[ref]/graphiql/index.tsx b/studio/pages/project/[ref]/graphiql/index.tsx
index b7382665d15..e5a6538d890 100644
--- a/studio/pages/project/[ref]/graphiql/index.tsx
+++ b/studio/pages/project/[ref]/graphiql/index.tsx
@@ -6,14 +6,14 @@ 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, useStore } from 'hooks'
-import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'
+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 } = useParams()
+ const { ref: projectRef } = useParams()
const { ui, meta } = useStore()
const isExtensionsLoading = meta.extensions.isLoading
@@ -28,25 +28,26 @@ const GraphiQLPage: NextPageWithLayout = () => {
}, [ui.selectedProject?.ref])
const {
- services,
+ data: settings,
isError: isProjectSettingsError,
isLoading: isProjectSettingsLoading,
- } = useProjectSettings(ref)
+ } = useProjectApiQuery({
+ projectRef,
+ })
- const apiService = (services ?? []).find((x: any) => x.app.id == DEFAULT_PROJECT_API_SERVICE_ID)
- const apiConfig = apiService?.app_config ?? {}
- const apiKeys = apiService?.service_api_keys ?? []
+ 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 graphqlUrl = `https://${apiConfig.endpoint}/graphql/v1`
- const anonKey = apiKeys.find((key: any) => key.tags === 'anon')?.api_key
+ const graphqlUrl = `https://${endpoint}/graphql/v1`
const fetcher = useMemo(() => {
return createGraphiQLFetcher({
url: graphqlUrl,
fetch,
- headers: {
- apikey: anonKey,
- },
+ ...(anonKey && { headers: { apikey: anonKey } }),
})
}, [graphqlUrl, anonKey])