Skip to content

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

moves apiKey header to graphiql headers section

Alaister Young2f3c67a56e24
diff --git a/studio/components/interfaces/GraphQL/GraphiQL.tsx b/studio/components/interfaces/GraphQL/GraphiQL.tsx
index de419530f14..f52a378157d 100644
--- a/studio/components/interfaces/GraphQL/GraphiQL.tsx
+++ b/studio/components/interfaces/GraphQL/GraphiQL.tsx
@@ -44,9 +44,10 @@ import styles from './graphiql.module.css'
export type GraphiQLProps = {
fetcher: Fetcher
theme?: 'dark' | 'light'
+ apiKey?: string
}
-const GraphiQL = ({ fetcher, theme = 'dark' }: GraphiQLProps) => {
+const GraphiQL = ({ fetcher, theme = 'dark', apiKey }: GraphiQLProps) => {
// Ensure props are correct
if (typeof fetcher !== 'function') {
throw new TypeError(
@@ -55,7 +56,7 @@ const GraphiQL = ({ fetcher, theme = 'dark' }: GraphiQLProps) => {
}
return (
- <GraphiQLProvider fetcher={fetcher}>
+ <GraphiQLProvider fetcher={fetcher} defaultHeaders={JSON.stringify({ apiKey }, null, 2)}>
<GraphiQLInterface theme={theme} />
</GraphiQLProvider>
)
diff --git a/studio/pages/project/[ref]/api/graphiql.tsx b/studio/pages/project/[ref]/api/graphiql.tsx
index 4e11726744f..8b449994aee 100644
--- a/studio/pages/project/[ref]/api/graphiql.tsx
+++ b/studio/pages/project/[ref]/api/graphiql.tsx
@@ -46,9 +46,8 @@ const GraphiQLPage: NextPageWithLayout = () => {
return createGraphiQLFetcher({
url: graphqlUrl,
fetch,
- ...(anonKey && { headers: { apikey: anonKey } }),
})
- }, [graphqlUrl, anonKey])
+ }, [graphqlUrl])
if (isProjectSettingsLoading || (isExtensionsLoading && !pgGraphqlExtension)) {
return <Connecting />
@@ -70,7 +69,7 @@ const GraphiQLPage: NextPageWithLayout = () => {
<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
+ Toggle the switch below to enable the GraphQL extension. You can then use the GraphQL
API with your Supabase Database.
</h2>
</div>
@@ -81,7 +80,7 @@ const GraphiQLPage: NextPageWithLayout = () => {
)
}
- return <GraphiQL fetcher={fetcher} theme={ui.theme} />
+ return <GraphiQL fetcher={fetcher} theme={ui.theme} apiKey={anonKey} />
}
GraphiQLPage.getLayout = (page) => <DocsLayout title="GraphiQL">{page}</DocsLayout>