-
Notifications
You must be signed in to change notification settings - Fork 22
/
graphiql.html
37 lines (35 loc) · 1.02 KB
/
graphiql.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<html>
<head>
<title>GraphiQL-WP</title>
<link href="https://unpkg.com/graphiql/graphiql.min.css" rel="stylesheet" />
</head>
<body style="margin: 0;">
<div id="graphiql" style="height: 100vh;"></div>
<script
crossorigin
src="https://unpkg.com/react/umd/react.production.min.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"
></script>
<script
crossorigin
src="https://unpkg.com/graphiql/graphiql.min.js"
></script>
<script>
const graphQLFetcher = (graphQLParams) =>
fetch("/graphql", {
method: "post",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(graphQLParams),
})
.then((response) => response.json())
.catch(() => response.text());
ReactDOM.render(
React.createElement(GraphiQL, { fetcher: graphQLFetcher }),
document.getElementById("graphiql")
);
</script>
</body>
</html>