diff --git a/.changeset/twelve-vans-sell.md b/.changeset/twelve-vans-sell.md new file mode 100644 index 0000000000..25c4a077fd --- /dev/null +++ b/.changeset/twelve-vans-sell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-graphiql': patch +--- + +Allow to pass lazy GraphQL endpoint URL diff --git a/plugins/graphiql/api-report.md b/plugins/graphiql/api-report.md index c96966c585..ea765d4d2b 100644 --- a/plugins/graphiql/api-report.md +++ b/plugins/graphiql/api-report.md @@ -16,7 +16,7 @@ import { RouteRef } from '@backstage/core-plugin-api'; export type EndpointConfig = { id: string; title: string; - url: string; + url: string | Promise; method?: 'POST'; headers?: { [name in string]: string; diff --git a/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts b/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts index 7f9c0ca4ee..52dc40fd81 100644 --- a/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts +++ b/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts @@ -26,7 +26,7 @@ export type EndpointConfig = { id: string; title: string; // Endpoint URL - url: string; + url: string | Promise; // only supports POST right now method?: 'POST'; // Defaults to setting Content-Type to application/json @@ -66,7 +66,7 @@ export class GraphQLEndpoints implements GraphQLBrowseApi { ...config.headers, ...options.headers, }; - const res = await fetch(url, { + const res = await fetch(await url, { method, headers, body,