graphiql - init web interface

This commit is contained in:
pluggpreagar - 2022-03-09 08:10:35 +01:00
parent 9bc11c5bb8
commit e3fee57a94
1 changed files with 16 additions and 47 deletions

View File

@ -1,59 +1,28 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <title>Simple GraphiQL Example</title>
<style> <link href="https://unpkg.com/graphiql/graphiql.min.css" rel="stylesheet" />
body { <!--<link rel="stylesheet" href="/assets/graphiql/graphiql.css">-->
height: 100%; </head>
margin: 0; <body style="margin: 0;">
width: 100%; <div id="graphiql" style="height: 100vh;"></div>
overflow: hidden;
} <script crossorigin src="https://unpkg.com/react/umd/react.production.min.js"></script>
#graphiql { <script crossorigin src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
height: 100vh; <script crossorigin src="https://unpkg.com/graphiql/graphiql.min.js"></script>
} <!--
</style>
<link rel="stylesheet" href="/assets/graphiql/graphiql.css">
<script src="/assets/react/umd/react.development.js"></script> <script src="/assets/react/umd/react.development.js"></script>
<script src="/assets/react-dom/umd/react-dom.development.js"></script> <script src="/assets/react-dom/umd/react-dom.development.js"></script>
<script src="/assets/graphiql/graphiql.js"></script> <script src="/assets/graphiql/graphiql.js"></script>
-->
</head>
<body>
<div id="graphiql">Loading...</div>
<script> <script>
// This expects a GraphQL server at the path /graphql.
const fetcher = GraphiQL.createFetcher({ url: '/graphql' });
function graphQLFetcher(graphQLParams) {
// This example expects a GraphQL server at the path /graphql.
// Change this to point wherever you host your GraphQL server.
return fetch('/graphql', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(graphQLParams),
credentials: 'include',
}).then(function (response) {
return response.text();
}).then(function (responseBody) {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
}
// Render <GraphiQL /> into the body.
// See the GraphiQL project page for more info on different options.
ReactDOM.render( ReactDOM.render(
React.createElement(GraphiQL, { React.createElement(GraphiQL, { fetcher: fetcher }),
fetcher: graphQLFetcher document.getElementById('graphiql'),
}),
document.getElementById('graphiql')
); );
</script> </script>
</body> </body>