Skip to content

Commit bb819f9

Browse files
committed
Add GraphiQL Explorer plugin in embedded integration
Closes gh-777
1 parent 130e08f commit bb819f9

File tree

1 file changed

+5
-3
lines changed
  • spring-graphql/src/main/resources/graphiql

1 file changed

+5
-3
lines changed

spring-graphql/src/main/resources/graphiql/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
1919
<script src="https://unpkg.com/graphiql/graphiql.min.js" type="application/javascript"></script>
2020
<link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
21+
<script src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js" crossorigin></script>
22+
<link rel="stylesheet" href="https://unpkg.com/@graphiql/plugin-explorer/dist/style.css"/>
2123
</head>
2224
<body>
2325
<div id="graphiql">Loading...</div>
2426
<script>
2527
const params = new URLSearchParams(window.location.search);
26-
2728
const path = params.get("path") || "/graphql";
2829
const url = `${location.protocol}//${location.host}${path}`;
29-
3030
const wsPath = params.get("wsPath") || "/graphql";
3131
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
3232
const subscriptionUrl = `${wsProtocol}//${location.host}${wsPath}`;
@@ -36,12 +36,14 @@
3636
subscriptionUrl,
3737
});
3838

39+
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
3940
ReactDOM.render(
4041
React.createElement(GraphiQL, {
4142
fetcher: gqlFetcher,
4243
defaultVariableEditorOpen: true,
4344
headerEditorEnabled: true,
44-
shouldPersistHeaders: true
45+
shouldPersistHeaders: true,
46+
plugins: [explorerPlugin]
4547
}),
4648
document.getElementById('graphiql'),
4749
);

0 commit comments

Comments
 (0)