This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
108 lines (106 loc) · 3.31 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"
/>
<title>GraphQL Visualizer</title>
<meta itemprop="name" property="og:title" content="GraphQL Visualizer" />
<meta
property="og:description"
content="Visually represents GraphQL schemas, making it easy for developers to understand and explore them."
/>
<meta
itemprop="description"
name="description"
content="Visually represents GraphQL schemas, making it easy for developers to understand and explore them."
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="icons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="96x96"
href="icons/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="icons/favicon-16x16.png"
/>
<meta itemprop="image" property="og:type" content="website" />
<meta
itemprop="image"
property="og:url"
content="https://graphql-visualizer.rhea-so.link/"
/>
<meta
itemprop="image"
property="og:image"
content="https://graphql-visualizer.rhea-so.link/images/cover-image.png"
/>
<meta name="theme-color" content="#ffffff" />
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#voyager {
height: 100vh;
}
</style>
<script src="https://graphql-visualizer.rhea-so.link/libs/react.min.js"></script>
<script src="https://graphql-visualizer.rhea-so.link/libs/react-dom.min.js"></script>
<link rel="stylesheet" href="https://graphql-visualizer.rhea-so.link/libs/voyager.css"/>
<script src="https://graphql-visualizer.rhea-so.link/libs/voyager.min.js"></script>
</head>
<body>
<div id="voyager">Loading...</div>
<script>
function findGetParameter(parameterName) {
let result = null, tmp = [];
let items = location.search.substr(1).split("&");
for (let index = 0; index < items.length; index++) {
tmp = items[index].split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}
function introspectionProvider(introspectionQuery) {
const address = findGetParameter('url');
if (!address || address == 'null') {
window.location = `https://graphql-visualizer.rhea-so.link/?url=${prompt('Input your graphql server address\n(Example: http://localhost:8080/graphql)')}`;
}
return fetch(address, {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ query: introspectionQuery })
})
.then(function (response) {
return response.text();
})
.then(function (responseBody) {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
}
GraphQLVoyager.init(document.getElementById('voyager'), {
introspection: introspectionProvider,
});
</script>
</body>
</html>