Last active
December 3, 2021 16:00
-
-
Save hanachin/874eccafa1176ae3e607fdca45dbea9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Simple GraphiQL Example</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 type="module"> | |
await import('https://unpkg.com/react/umd/react.production.min.js') | |
await import('https://unpkg.com/react-dom/umd/react-dom.production.min.js') | |
await import('https://unpkg.com/graphiql/graphiql.min.js') | |
const graphQLFetcher = graphQLParams => | |
fetch('http://localhost:4567/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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment