mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
<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 |
|
crossorigin |
|
src="https://unpkg.com/react/umd/react.production.min.js" |
|
></script> |
|
<script |
|
crossorigin |
|
src="https://unpkg.com/react-dom/umd/react-dom.production.min.js" |
|
></script> |
|
<script |
|
crossorigin |
|
src="https://unpkg.com/graphiql/graphiql.min.js" |
|
></script> |
|
|
|
<script> |
|
const graphQLFetcher = graphQLParams => |
|
fetch(`https://${location.hostname}/api/graphql-engine/v1/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> |