add env to handle graphql endpoint for graphiql-online (#1178)

[skip ci]
This commit is contained in:
Praveen Durairaj 2018-12-11 14:31:46 +05:30 committed by Shahidh K Muhammed
parent 2855e07b11
commit 12231bc062
2 changed files with 21 additions and 3 deletions

View File

@ -6,13 +6,23 @@ import { push } from 'react-router-redux';
class ApiExplorer extends Component {
componentWillMount() {
const localStorageUrl = window.localStorage.getItem('ONLINE_GRAPHIQL_ENDPOINT');
if (!this.props.graphqlEndpoint && localStorageUrl === null) {
let localStorageUrl;
if (window.__env.graphqlEndpoint && window.__env.graphqlEndpoint !== 'undefined') {
localStorageUrl = window.__env.graphqlEndpoint;
} else {
localStorageUrl = window.localStorage.getItem('ONLINE_GRAPHIQL_ENDPOINT');
}
if (!this.props.graphqlEndpoint && (localStorageUrl === 'undefined' || localStorage === null)) {
this.props.dispatch(push('/'));
}
}
render() {
const localStorageUrl = window.localStorage.getItem('ONLINE_GRAPHIQL_ENDPOINT');
let localStorageUrl;
if (window.__env.graphqlEndpoint && window.__env.graphqlEndpoint !== 'undefined') {
localStorageUrl = window.__env.graphqlEndpoint;
} else {
localStorageUrl = window.localStorage.getItem('ONLINE_GRAPHIQL_ENDPOINT');
}
const styles = require('./ApiExplorer.scss');
const wrapperClass = styles.apiExplorerWrapper;
const requestStyles = '';

View File

@ -1,5 +1,13 @@
<html lang="en-us">
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130585335-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-130585335-1');
</script>
<link rel="icon" type="image/png" href="./favicon.png" />
<title>GraphiQL Online with Headers | Built by Hasura</title>
<meta name="title" content="GraphiQL Online with Headers | Built by Hasura" />