diff --git a/spring-graphql/src/main/resources/graphiql/index.html b/spring-graphql/src/main/resources/graphiql/index.html index 36bb6360..a3a4671a 100644 --- a/spring-graphql/src/main/resources/graphiql/index.html +++ b/spring-graphql/src/main/resources/graphiql/index.html @@ -19,20 +19,22 @@ font-size: 4rem; } - - + + @@ -42,33 +44,18 @@ import { GraphiQL, HISTORY_PLUGIN } from 'graphiql'; import { createGraphiQLFetcher } from '@graphiql/toolkit'; import { explorerPlugin } from '@graphiql/plugin-explorer'; - - import createJSONWorker from 'https://esm.sh/monaco-editor/esm/vs/language/json/json.worker.js?worker'; - import createGraphQLWorker from 'https://esm.sh/monaco-graphql/esm/graphql.worker.js?worker'; - import createEditorWorker from 'https://esm.sh/monaco-editor/esm/vs/editor/editor.worker.js?worker'; - - globalThis.MonacoEnvironment = { - getWorker(_workerId, label) { - switch (label) { - case 'json': - return createJSONWorker(); - case 'graphql': - return createGraphQLWorker(); - } - return createEditorWorker(); - }, - }; + import 'graphiql/setup-workers/esm.sh'; const params = new URLSearchParams(window.location.search); - const path = params.get("path") || "/graphql"; + const path = params.get('path') || '/graphql'; const url = `${location.protocol}//${location.host}${path}`; - const wsPath = params.get("wsPath") || "/graphql"; + const wsPath = params.get('wsPath') || '/graphql'; const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; const subscriptionUrl = `${wsProtocol}//${location.host}${wsPath}`; const gqlFetcher = createGraphiQLFetcher({'url': url, 'subscriptionUrl': subscriptionUrl}); const plugins = [HISTORY_PLUGIN, explorerPlugin()]; const xsrfToken = document.cookie.match(new RegExp('(?:^| )XSRF-TOKEN=([^;]+)')); - const initialHeaders = xsrfToken ? `{ "X-XSRF-TOKEN" : "${ xsrfToken[1] }" }` : `{}`; + const initialHeaders = xsrfToken ? `{ 'X-XSRF-TOKEN' : '${ xsrfToken[1] }' }` : undefined; function App() { return React.createElement(GraphiQL, { @@ -87,6 +74,6 @@
-