From 1cd827c6bb43e6890a95569c159e184806e632af Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 14 Aug 2017 11:56:34 -0700 Subject: [PATCH] Catch graphql schema render errors --- app/ui/components/editors/body/graph-ql-editor.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui/components/editors/body/graph-ql-editor.js b/app/ui/components/editors/body/graph-ql-editor.js index 5a121b3f5..e5c36edd8 100644 --- a/app/ui/components/editors/body/graph-ql-editor.js +++ b/app/ui/components/editors/body/graph-ql-editor.js @@ -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});