-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Right now I have this file in a utils.js somewhere on my server.
It would be sweet if I didn't need to rely on any other services here and really utilize the npm dependency. This feels kind of hacky.
export let staticDocsHTML = () => {
return `
<!DOCTYPE html>
<html>
<head>
<title>GraphQL Docs</title>
</head>
<body>
<div id="app"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.2/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script src="https://github.com/mhallin/graphql-docs/releases/download/v0.1.4/graphql-docs.min.js"></script>
<script>
function fetcher(query) {
return fetch(window.location.origin + '/graphql', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
}),
}).then(function(r) {
return r.json();
});
}
const rootElem = document.getElementById('app');
ReactDOM.render(
React.createElement(
GraphQLDocs.GraphQLDocs,
{
fetcher: fetcher,
}),
rootElem
);
</script>
</body>
</html>
`
}
ikari-pl
Metadata
Metadata
Assignees
Labels
No labels