-
-
Notifications
You must be signed in to change notification settings - Fork 523
/
Copy pathindex.html
53 lines (49 loc) · 1.35 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!doctype html>
<html>
<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#voyager {
height: 100vh;
}
</style>
<!--
These two files are served from jsdelivr CDN, however you may wish to
copy them directly into your environment, or perhaps include them in your
favored resource bundler.
-->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.css"
/>
<script src="https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.standalone.js"></script>
</head>
<body>
<div id="voyager">Loading...</div>
<script type="module">
const { voyagerIntrospectionQuery: query } = GraphQLVoyager;
const response = await fetch(
'https://swapi-graphql.netlify.app/.netlify/functions/index',
{
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
credentials: 'omit',
},
);
const introspection = await response.json();
// Render <Voyager /> into the body.
GraphQLVoyager.renderVoyager(document.getElementById('voyager'), {
introspection,
});
</script>
</body>
</html>