Skip to content

Commit

Permalink
fix: renderVoyager
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaticMuch committed Sep 4, 2023
1 parent de3e0dc commit 5ea06f7
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions example/cdn/index.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
<!doctype html>
<html>
<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#voyager {
height: 100vh;
}
</style>

<!--
<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 { init, 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',
<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',
},
);
const introspection = await response.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>

// Render <Voyager /> into the body.
GraphQLVoyager.init(document.getElementById('voyager'), {
introspection,
});
</script>
</body>
</html>
</html>

0 comments on commit 5ea06f7

Please sign in to comment.