Catch graphql schema render errors

This commit is contained in:
Gregory Schier 2017-08-14 11:56:34 -07:00
parent 22d0346864
commit 1cd827c6bb

View File

@ -81,7 +81,7 @@ class GraphQLEditor extends React.PureComponent {
this.setState({schemaIsFetching: true});
const {workspace, settings, environmentId} = this.props;
const request: RenderedRequest = await getRenderedRequest(rawRequest, environmentId);
const newState = {
schema: this.state.schema,
schemaFetchError: '',
@ -89,6 +89,15 @@ class GraphQLEditor extends React.PureComponent {
schemaIsFetching: false
};
let request: RenderedRequest;
try {
request = await getRenderedRequest(rawRequest, environmentId);
} catch (err) {
newState.schemaFetchError = `Failed to fetch schema: ${err}`;
this.setState(newState);
return;
}
try {
// TODO: Use Insomnia's network stack to handle things like authentication
const bodyJson = JSON.stringify({query: introspectionQuery});