@backstage-community/plugin-apollo-explorer 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{esm/index-BgwBzs82.esm.js → components/ApolloExplorerBrowser/ApolloExplorerBrowser.esm.js} +4 -10
- package/dist/components/ApolloExplorerBrowser/ApolloExplorerBrowser.esm.js.map +1 -0
- package/dist/components/ApolloExplorerPage/ApolloExplorerPage.esm.js +11 -0
- package/dist/components/ApolloExplorerPage/ApolloExplorerPage.esm.js.map +1 -0
- package/dist/components/ApolloExplorerPage/index.esm.js +2 -0
- package/dist/components/ApolloExplorerPage/index.esm.js.map +1 -0
- package/dist/index.esm.js +1 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +19 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +10 -6
- package/dist/esm/index-BgwBzs82.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Content, Page, Header } from '@backstage/core-components';
|
|
3
2
|
import Divider from '@material-ui/core/Divider';
|
|
4
3
|
import Tab from '@material-ui/core/Tab';
|
|
5
4
|
import Tabs from '@material-ui/core/Tabs';
|
|
6
5
|
import { makeStyles } from '@material-ui/core/styles';
|
|
7
6
|
import { ApolloExplorer } from '@apollo/explorer/react';
|
|
7
|
+
import { Content } from '@backstage/core-components';
|
|
8
8
|
import { useApiHolder } from '@backstage/core-plugin-api';
|
|
9
9
|
|
|
10
10
|
const useStyles = makeStyles((theme) => ({
|
|
@@ -41,8 +41,7 @@ const ApolloExplorerBrowser = ({ endpoints }) => {
|
|
|
41
41
|
const apiHolder = useApiHolder();
|
|
42
42
|
const getAuthCallback = (index) => {
|
|
43
43
|
const authCallback = endpoints[index].authCallback;
|
|
44
|
-
if (authCallback === void 0)
|
|
45
|
-
return void 0;
|
|
44
|
+
if (authCallback === void 0) return void 0;
|
|
46
45
|
return () => authCallback({ apiHolder });
|
|
47
46
|
};
|
|
48
47
|
return /* @__PURE__ */ React.createElement("div", { className: classes.root }, /* @__PURE__ */ React.createElement(
|
|
@@ -68,10 +67,5 @@ const ApolloExplorerBrowser = ({ endpoints }) => {
|
|
|
68
67
|
)));
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return /* @__PURE__ */ React.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React.createElement(Header, { title: title != null ? title : "Apollo Explorer \u{1F469}\u200D\u{1F680}", subtitle: subtitle != null ? subtitle : "" }), /* @__PURE__ */ React.createElement(Content, { noPadding: true }, /* @__PURE__ */ React.createElement(ApolloExplorerBrowser, { endpoints })));
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export { ApolloExplorerPage };
|
|
77
|
-
//# sourceMappingURL=index-BgwBzs82.esm.js.map
|
|
70
|
+
export { ApolloExplorerBrowser, handleAuthRequest };
|
|
71
|
+
//# sourceMappingURL=ApolloExplorerBrowser.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApolloExplorerBrowser.esm.js","sources":["../../../src/components/ApolloExplorerBrowser/ApolloExplorerBrowser.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport Divider from '@material-ui/core/Divider';\nimport Tab from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ApolloExplorer } from '@apollo/explorer/react';\nimport { Content } from '@backstage/core-components';\nimport { HandleRequest } from '@apollo/explorer/src/helpers/postMessageRelayHelpers';\nimport { EndpointProps } from '../ApolloExplorerPage';\nimport { useApiHolder } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles(theme => ({\n tabs: {\n background: theme.palette.background.paper,\n },\n root: {\n height: '100%',\n },\n content: {\n height: '100%',\n },\n explorer: {\n height: '95%',\n },\n}));\n\ntype Props = {\n endpoints: EndpointProps[];\n authCallback?: () => Promise<{ token: string }>;\n};\n\nexport const handleAuthRequest = ({\n authCallback,\n}: {\n authCallback: Props['authCallback'];\n}): HandleRequest => {\n const handleRequest: HandleRequest = async (endpointUrl, options) =>\n fetch(endpointUrl, {\n ...options,\n headers: {\n ...options.headers,\n ...(authCallback && {\n Authorization: `Bearer ${(await authCallback()).token}`,\n }),\n },\n });\n return handleRequest;\n};\n\nexport const ApolloExplorerBrowser = ({ endpoints }: Props) => {\n const classes = useStyles();\n const [tabIndex, setTabIndex] = useState(0);\n\n const apiHolder = useApiHolder();\n\n const getAuthCallback = (index: number) => {\n const authCallback = endpoints[index].authCallback;\n if (authCallback === undefined) return undefined;\n return () => authCallback({ apiHolder });\n };\n\n return (\n <div className={classes.root}>\n <Tabs\n classes={{ root: classes.tabs }}\n value={tabIndex}\n onChange={(_, value) => setTabIndex(value)}\n indicatorColor=\"primary\"\n >\n {endpoints.map(({ title }, index) => (\n <Tab key={index} label={title} value={index} />\n ))}\n </Tabs>\n <Divider />\n <Content className={classes.content}>\n <ApolloExplorer\n className={classes.explorer}\n graphRef={endpoints[tabIndex].graphRef}\n handleRequest={handleAuthRequest({\n authCallback: getAuthCallback(tabIndex),\n })}\n persistExplorerState={endpoints[tabIndex].persistExplorerState}\n initialState={endpoints[tabIndex].initialState}\n />\n </Content>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA2BA,MAAM,SA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
import { ApolloExplorerBrowser } from '../ApolloExplorerBrowser/ApolloExplorerBrowser.esm.js';
|
|
4
|
+
|
|
5
|
+
const ApolloExplorerPage = (props) => {
|
|
6
|
+
const { title, subtitle, endpoints } = props;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React.createElement(Header, { title: title ?? "Apollo Explorer \u{1F469}\u200D\u{1F680}", subtitle: subtitle ?? "" }), /* @__PURE__ */ React.createElement(Content, { noPadding: true }, /* @__PURE__ */ React.createElement(ApolloExplorerBrowser, { endpoints })));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { ApolloExplorerPage };
|
|
11
|
+
//# sourceMappingURL=ApolloExplorerPage.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApolloExplorerPage.esm.js","sources":["../../../src/components/ApolloExplorerPage/ApolloExplorerPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { Content, Header, Page } from '@backstage/core-components';\nimport { ApolloExplorerBrowser } from '../ApolloExplorerBrowser';\nimport { JSONObject } from '@apollo/explorer/src/helpers/types';\nimport { ApiHolder } from '@backstage/core-plugin-api';\n\n/**\n * Export types to be used with {@link @backstage/apollo-explorer#ApolloExplorerPage}.\n *\n * @public\n */\nexport type EndpointProps = {\n title: string;\n graphRef: string;\n authCallback?: AuthCallback;\n persistExplorerState?: boolean;\n initialState?: {\n document?: string;\n variables?: JSONObject;\n headers?: Record<string, string>;\n displayOptions: {\n docsPanelState?: 'open' | 'closed';\n showHeadersAndEnvVars?: boolean;\n theme?: 'dark' | 'light';\n };\n };\n};\n\n/**\n * Export types to be used with {@link @backstage/apollo-explorer#ApolloExplorerPage}.\n *\n * @public\n */\nexport type AuthCallback = (options: {\n apiHolder: ApiHolder;\n}) => Promise<{ token: string }>;\n\ntype Props = {\n title?: string | undefined;\n subtitle?: string | undefined;\n endpoints: EndpointProps[];\n};\n\nexport const ApolloExplorerPage = (props: Props) => {\n const { title, subtitle, endpoints } = props;\n\n return (\n <Page themeId=\"tool\">\n <Header title={title ?? 'Apollo Explorer 👩🚀'} subtitle={subtitle ?? ''} />\n <Content noPadding>\n <ApolloExplorerBrowser endpoints={endpoints} />\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;AA2Da,MAAA,kBAAA,GAAqB,CAAC,KAAiB,KAAA;AAClD,EAAA,MAAM,EAAE,KAAA,EAAO,QAAU,EAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAEvC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,OAAQ,EAAA,MAAA,EAAA,sCACX,MAAO,EAAA,EAAA,KAAA,EAAO,SAAS,0CAAyB,EAAA,QAAA,EAAU,YAAY,EAAI,EAAA,CAAA,sCAC1E,OAAQ,EAAA,EAAA,SAAA,EAAS,wBACf,KAAA,CAAA,aAAA,CAAA,qBAAA,EAAA,EAAsB,SAAsB,EAAA,CAC/C,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const rootRouteRef = createRouteRef({
|
|
4
|
-
id: "apollo-explorer"
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
const apolloExplorerPlugin = createPlugin({
|
|
8
|
-
id: "apollo-explorer",
|
|
9
|
-
routes: {
|
|
10
|
-
root: rootRouteRef
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
const ApolloExplorerPage = apolloExplorerPlugin.provide(
|
|
14
|
-
createRoutableExtension({
|
|
15
|
-
name: "ApolloExplorerPage",
|
|
16
|
-
component: () => import('./esm/index-BgwBzs82.esm.js').then((m) => m.ApolloExplorerPage),
|
|
17
|
-
mountPoint: rootRouteRef
|
|
18
|
-
})
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export { ApolloExplorerPage, apolloExplorerPlugin };
|
|
1
|
+
export { ApolloExplorerPage, apolloExplorerPlugin } from './plugin.esm.js';
|
|
22
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createPlugin, createRoutableExtension } from '@backstage/core-plugin-api';
|
|
2
|
+
import { rootRouteRef } from './routes.esm.js';
|
|
3
|
+
|
|
4
|
+
const apolloExplorerPlugin = createPlugin({
|
|
5
|
+
id: "apollo-explorer",
|
|
6
|
+
routes: {
|
|
7
|
+
root: rootRouteRef
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
const ApolloExplorerPage = apolloExplorerPlugin.provide(
|
|
11
|
+
createRoutableExtension({
|
|
12
|
+
name: "ApolloExplorerPage",
|
|
13
|
+
component: () => import('./components/ApolloExplorerPage/index.esm.js').then((m) => m.ApolloExplorerPage),
|
|
14
|
+
mountPoint: rootRouteRef
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export { ApolloExplorerPage, apolloExplorerPlugin };
|
|
19
|
+
//# sourceMappingURL=plugin.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createPlugin,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\n\n/**\n * Plugin that allows Apollo Explorer instances to be directly embedded into Backstage\n * @public\n */\nexport const apolloExplorerPlugin = createPlugin({\n id: 'apollo-explorer',\n routes: {\n root: rootRouteRef,\n },\n});\n\n/**\n * Main component that wraps the embedded graph(s)\n * @public\n */\nexport const ApolloExplorerPage = apolloExplorerPlugin.provide(\n createRoutableExtension({\n name: 'ApolloExplorerPage',\n component: () =>\n import('./components/ApolloExplorerPage').then(m => m.ApolloExplorerPage),\n mountPoint: rootRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;AA0BO,MAAM,uBAAuB,YAAa,CAAA;AAAA,EAC/C,EAAI,EAAA,iBAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,GACR;AACF,CAAC,EAAA;AAMM,MAAM,qBAAqB,oBAAqB,CAAA,OAAA;AAAA,EACrD,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,oBAAA;AAAA,IACN,SAAA,EAAW,MACT,OAAO,8CAAiC,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,kBAAkB,CAAA;AAAA,IAC1E,UAAY,EAAA,YAAA;AAAA,GACb,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'apollo-explorer',\n});\n"],"names":[],"mappings":";;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA,iBAAA;AACN,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-apollo-explorer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"backstage": {
|
|
5
|
-
"role": "frontend-plugin"
|
|
5
|
+
"role": "frontend-plugin",
|
|
6
|
+
"pluginId": "apollo-explorer",
|
|
7
|
+
"pluginPackages": [
|
|
8
|
+
"@backstage-community/plugin-apollo-explorer"
|
|
9
|
+
]
|
|
6
10
|
},
|
|
7
11
|
"publishConfig": {
|
|
8
12
|
"access": "public",
|
|
@@ -33,8 +37,8 @@
|
|
|
33
37
|
},
|
|
34
38
|
"dependencies": {
|
|
35
39
|
"@apollo/explorer": "^3.0.0",
|
|
36
|
-
"@backstage/core-components": "^0.14.
|
|
37
|
-
"@backstage/core-plugin-api": "^1.9.
|
|
40
|
+
"@backstage/core-components": "^0.14.10",
|
|
41
|
+
"@backstage/core-plugin-api": "^1.9.3",
|
|
38
42
|
"@material-ui/core": "^4.12.2",
|
|
39
43
|
"@material-ui/lab": "^4.0.0-alpha.61",
|
|
40
44
|
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
@@ -42,8 +46,8 @@
|
|
|
42
46
|
"use-deep-compare-effect": "^1.8.1"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@backstage/cli": "^0.
|
|
46
|
-
"@backstage/dev-utils": "^1.0.
|
|
49
|
+
"@backstage/cli": "^0.27.0",
|
|
50
|
+
"@backstage/dev-utils": "^1.0.37",
|
|
47
51
|
"@testing-library/dom": "^10.0.0",
|
|
48
52
|
"@testing-library/jest-dom": "^6.0.0",
|
|
49
53
|
"@testing-library/react": "^15.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BgwBzs82.esm.js","sources":["../../src/components/ApolloExplorerBrowser/ApolloExplorerBrowser.tsx","../../src/components/ApolloExplorerPage/ApolloExplorerPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport Divider from '@material-ui/core/Divider';\nimport Tab from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ApolloExplorer } from '@apollo/explorer/react';\nimport { Content } from '@backstage/core-components';\nimport { HandleRequest } from '@apollo/explorer/src/helpers/postMessageRelayHelpers';\nimport { EndpointProps } from '../ApolloExplorerPage';\nimport { useApiHolder } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles(theme => ({\n tabs: {\n background: theme.palette.background.paper,\n },\n root: {\n height: '100%',\n },\n content: {\n height: '100%',\n },\n explorer: {\n height: '95%',\n },\n}));\n\ntype Props = {\n endpoints: EndpointProps[];\n authCallback?: () => Promise<{ token: string }>;\n};\n\nexport const handleAuthRequest = ({\n authCallback,\n}: {\n authCallback: Props['authCallback'];\n}): HandleRequest => {\n const handleRequest: HandleRequest = async (endpointUrl, options) =>\n fetch(endpointUrl, {\n ...options,\n headers: {\n ...options.headers,\n ...(authCallback && {\n Authorization: `Bearer ${(await authCallback()).token}`,\n }),\n },\n });\n return handleRequest;\n};\n\nexport const ApolloExplorerBrowser = ({ endpoints }: Props) => {\n const classes = useStyles();\n const [tabIndex, setTabIndex] = useState(0);\n\n const apiHolder = useApiHolder();\n\n const getAuthCallback = (index: number) => {\n const authCallback = endpoints[index].authCallback;\n if (authCallback === undefined) return undefined;\n return () => authCallback({ apiHolder });\n };\n\n return (\n <div className={classes.root}>\n <Tabs\n classes={{ root: classes.tabs }}\n value={tabIndex}\n onChange={(_, value) => setTabIndex(value)}\n indicatorColor=\"primary\"\n >\n {endpoints.map(({ title }, index) => (\n <Tab key={index} label={title} value={index} />\n ))}\n </Tabs>\n <Divider />\n <Content className={classes.content}>\n <ApolloExplorer\n className={classes.explorer}\n graphRef={endpoints[tabIndex].graphRef}\n handleRequest={handleAuthRequest({\n authCallback: getAuthCallback(tabIndex),\n })}\n persistExplorerState={endpoints[tabIndex].persistExplorerState}\n initialState={endpoints[tabIndex].initialState}\n />\n </Content>\n </div>\n );\n};\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { Content, Header, Page } from '@backstage/core-components';\nimport { ApolloExplorerBrowser } from '../ApolloExplorerBrowser';\nimport { JSONObject } from '@apollo/explorer/src/helpers/types';\nimport { ApiHolder } from '@backstage/core-plugin-api';\n\n/**\n * Export types to be used with {@link @backstage/apollo-explorer#ApolloExplorerPage}.\n *\n * @public\n */\nexport type EndpointProps = {\n title: string;\n graphRef: string;\n authCallback?: AuthCallback;\n persistExplorerState?: boolean;\n initialState?: {\n document?: string;\n variables?: JSONObject;\n headers?: Record<string, string>;\n displayOptions: {\n docsPanelState?: 'open' | 'closed';\n showHeadersAndEnvVars?: boolean;\n theme?: 'dark' | 'light';\n };\n };\n};\n\n/**\n * Export types to be used with {@link @backstage/apollo-explorer#ApolloExplorerPage}.\n *\n * @public\n */\nexport type AuthCallback = (options: {\n apiHolder: ApiHolder;\n}) => Promise<{ token: string }>;\n\ntype Props = {\n title?: string | undefined;\n subtitle?: string | undefined;\n endpoints: EndpointProps[];\n};\n\nexport const ApolloExplorerPage = (props: Props) => {\n const { title, subtitle, endpoints } = props;\n\n return (\n <Page themeId=\"tool\">\n <Header title={title ?? 'Apollo Explorer 👩🚀'} subtitle={subtitle ?? ''} />\n <Content noPadding>\n <ApolloExplorerBrowser endpoints={endpoints} />\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA2BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,KAAA;AAAA,GACvC;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,MAAQ,EAAA,MAAA;AAAA,GACV;AAAA,EACA,OAAS,EAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,GACV;AAAA,EACA,QAAU,EAAA;AAAA,IACR,MAAQ,EAAA,KAAA;AAAA,GACV;AACF,CAAE,CAAA,CAAA,CAAA;AAOK,MAAM,oBAAoB,CAAC;AAAA,EAChC,YAAA;AACF,CAEqB,KAAA;AACnB,EAAA,MAAM,aAA+B,GAAA,OAAO,WAAa,EAAA,OAAA,KACvD,MAAM,WAAa,EAAA;AAAA,IACjB,GAAG,OAAA;AAA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