@@ -32,7 +32,7 @@ const defaultQuery = `# Welcome to the Tarkov.dev API Playground
32
32
33
33
const html = baseEndpoint => `
34
34
<!--
35
- * Copyright (c) 2021 GraphQL Contributors
35
+ * Copyright (c) 2025 GraphQL Contributors
36
36
* All rights reserved.
37
37
*
38
38
* This source code is licensed under the license found in the
@@ -41,76 +41,100 @@ const html = baseEndpoint => `
41
41
<!doctype html>
42
42
<html lang="en">
43
43
<head>
44
+ <meta charset="UTF-8" />
45
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
44
46
<title>Tarkov.dev API Playground</title>
45
47
<link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react/build/favicon.png" />
46
48
<style>
47
49
body {
48
- height: 100%;
49
50
margin: 0;
50
- width: 100%;
51
- overflow: hidden;
52
51
}
53
52
54
53
#graphiql {
55
- height: 100vh ;
54
+ height: 100dvh ;
56
55
}
57
- </style>
58
- <!--
59
- This GraphiQL example depends on Promise and fetch, which are available in
60
- modern browsers, but can be "polyfilled" for older browsers.
61
- GraphiQL itself depends on React DOM.
62
- If you do not want to rely on a CDN, you can host these files locally or
63
- include them directly in your favored resource bundler.
64
- -->
65
- <script
66
- crossorigin
67
- src="https://unpkg.com/react@18/umd/react.development.js"
68
- ></script>
69
- <script
70
- crossorigin
71
- src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
72
- ></script>
73
- <!--
74
- These two files can be found in the npm module, however you may wish to
75
- copy them directly into your environment, or perhaps include them in your
76
- favored resource bundler.
77
- -->
78
- <script
79
- src="https://unpkg.com/graphiql/graphiql.min.js"
80
- type="application/javascript"
81
- ></script>
82
- <link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
83
- <!--
84
- These are imports for the GraphIQL Explorer plugin.
85
- -->
86
- <script
87
- src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js"
88
- crossorigin
89
- ></script>
90
56
57
+ .loading {
58
+ height: 100%;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ font-size: 4rem;
63
+ }
64
+ </style>
65
+ <link rel="stylesheet" href="https://esm.sh/graphiql/dist/style.css" />
91
66
<link
92
67
rel="stylesheet"
93
- href="https://unpkg.com /@graphiql/plugin-explorer/dist/style.css"
68
+ href="https://esm.sh /@graphiql/plugin-explorer/dist/style.css"
94
69
/>
95
- </head>
70
+ <!-- Note: the ?standalone flag bundles the module along with all of its \`dependencies\`, excluding \`peerDependencies\`, into a single JavaScript file. -->
71
+ <script type="importmap">
72
+ {
73
+ "imports": {
74
+ "react": "https://esm.sh/[email protected] ",
75
+ "react/jsx-runtime": "https://esm.sh/[email protected] /jsx-runtime",
96
76
97
- <body>
98
- <div id="graphiql">Loading...</div>
99
- <script>
100
- const root = ReactDOM.createRoot(document.getElementById('graphiql'));
101
- const fetcher = GraphiQL.createFetcher({
77
+ "react-dom": "https://esm.sh/[email protected] ",
78
+ "react-dom/client": "https://esm.sh/[email protected] /client",
79
+
80
+ "graphiql": "https://esm.sh/graphiql?standalone&external=react,react-dom,@graphiql/react,graphql",
81
+ "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer?standalone&external=react,@graphiql/react,graphql",
82
+ "@graphiql/react": "https://esm.sh/@graphiql/react?standalone&external=react,react-dom,graphql",
83
+
84
+ "@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit?standalone&external=graphql",
85
+ "graphql": "https://esm.sh/[email protected] "
86
+ }
87
+ }
88
+ </script>
89
+ <script type="module">
90
+ // Import React and ReactDOM
91
+ import React from 'react';
92
+ import ReactDOM from 'react-dom/client';
93
+ // Import GraphiQL and the Explorer plugin
94
+ import { GraphiQL, HISTORY_PLUGIN } from 'graphiql';
95
+ import { createGraphiQLFetcher } from '@graphiql/toolkit';
96
+ import { explorerPlugin } from '@graphiql/plugin-explorer';
97
+
98
+ import createJSONWorker from 'https://esm.sh/monaco-editor/esm/vs/language/json/json.worker.js?worker';
99
+ import createGraphQLWorker from 'https://esm.sh/monaco-graphql/esm/graphql.worker.js?worker';
100
+ import createEditorWorker from 'https://esm.sh/monaco-editor/esm/vs/editor/editor.worker.js?worker';
101
+
102
+ globalThis.MonacoEnvironment = {
103
+ getWorker(_workerId, label) {
104
+ console.info('MonacoEnvironment.getWorker', { label });
105
+ switch (label) {
106
+ case 'json':
107
+ return createJSONWorker();
108
+ case 'graphql':
109
+ return createGraphQLWorker();
110
+ }
111
+ return createEditorWorker();
112
+ },
113
+ };
114
+
115
+ const fetcher = createGraphiQLFetcher({
102
116
url: '${ baseEndpoint } ',
103
117
});
104
- const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
105
- root.render(
106
- React.createElement(GraphiQL, {
118
+ const plugins = [HISTORY_PLUGIN, explorerPlugin()];
119
+
120
+ function App() {
121
+ return React.createElement(GraphiQL, {
107
122
fetcher,
123
+ plugins,
108
124
defaultEditorToolsVisibility: true,
109
- plugins: [explorerPlugin],
110
125
defaultQuery: \`${ defaultQuery } \`,
111
- }),
112
- );
126
+ });
127
+ }
128
+
129
+ const container = document.getElementById('graphiql');
130
+ const root = ReactDOM.createRoot(container);
131
+ root.render(React.createElement(App));
113
132
</script>
133
+ </head>
134
+ <body>
135
+ <div id="graphiql">
136
+ <div class="loading">Loading…</div>
137
+ </div>
114
138
</body>
115
139
</html>
116
140
`
0 commit comments