Skip to content

Commit 7493405

Browse files
feat: add graphiql explorer plugin (ExpediaGroup#1624)
1 parent 12bfc1e commit 7493405

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

servers/graphql-kotlin-spring-server/src/main/resources/graphql-graphiql.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,34 @@
5252
<div id="graphiql">Loading...</div>
5353
<script
5454
src="https://unpkg.com/graphiql/graphiql.min.js"
55-
type="application/javascript"
55+
integrity="sha512-FVCV2//UVo1qJ3Kg6kkHLe0Hg+IJhjrGa+aYHh8xD4KmwbbjthIzvaAcCJsQgA43+k+6u7HqORKXMyMt82Srfw=="
56+
crossorigin="anonymous"
57+
></script>
58+
<script
59+
src="https://unpkg.com/@graphiql/plugin-explorer@0.1.12/dist/graphiql-plugin-explorer.umd.js"
60+
integrity="sha512-Fjas/uSkzvsFjbv4jqU9nt4ulU7LDjiMAXW2YFTYD96NgKS1fhhAsGR4b2k2VaVLsE29aia3vyobAq9TNzusvA=="
61+
crossorigin="anonymous"
5662
></script>
5763
<script>
58-
ReactDOM.render(
59-
React.createElement(GraphiQL, {
64+
function GraphiQLWithExplorer() {
65+
var [query, setQuery] = React.useState('');
66+
var explorerPlugin = GraphiQLPluginExplorer.useExplorerPlugin({
67+
query: query,
68+
onEdit: setQuery,
69+
});
70+
return React.createElement(GraphiQL, {
6071
fetcher: GraphiQL.createFetcher({
6172
url: '/${graphQLEndpoint}',
6273
subscriptionUrl: '/${subscriptionsEndpoint}'
6374
}),
6475
defaultEditorToolsVisibility: true,
65-
}),
76+
plugins: [explorerPlugin],
77+
query: query,
78+
onEditQuery: setQuery,
79+
});
80+
}
81+
ReactDOM.render(
82+
React.createElement(GraphiQLWithExplorer),
6683
document.getElementById('graphiql'),
6784
);
6885
</script>

0 commit comments

Comments
 (0)