Created
August 11, 2021 16:37
-
-
Save patrick91/3ee7592d1f1c9bdc65838385910c5976 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body { | |
height: 100%; | |
margin: 0; | |
width: 100%; | |
overflow: hidden; | |
} | |
#graphiql { | |
height: 100vh; | |
} | |
</style> | |
<script | |
crossorigin | |
src="https://unpkg.com/react@16/umd/react.development.js" | |
></script> | |
<script | |
crossorigin | |
src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" | |
></script> | |
<link | |
rel="stylesheet" | |
href="https://unpkg.com/graphiql/graphiql.min.css" | |
/> | |
</head> | |
<body> | |
<div id="graphiql">Loading...</div> | |
<script | |
src="https://unpkg.com/graphiql/graphiql.min.js" | |
type="application/javascript" | |
></script> | |
<script> | |
function graphQLFetcher(graphQLParams, opts = { headers: {} }) { | |
return fetch(window.location.href, { | |
method: 'post', | |
headers: Object.assign( | |
{ 'Content-Type': 'application/json' }, | |
opts.headers, | |
), | |
body: JSON.stringify(graphQLParams), | |
credentials: 'omit', | |
}).then(function (response) { | |
return response.json().catch(function () { | |
return response.text(); | |
}); | |
}); | |
} | |
ReactDOM.render( | |
React.createElement(GraphiQL, { | |
fetcher: graphQLFetcher, | |
headerEditorEnabled: true, | |
headers: JSON.stringify({ | |
Authorization: 'JWT %TOKEN%', | |
}), | |
defaultVariableEditorOpen: true, | |
}), | |
document.getElementById('graphiql'), | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment