Fix flow error

This commit is contained in:
Gregory Schier 2017-08-14 12:04:46 -07:00
parent a570b3c1f8
commit eb0faa011e

View File

@ -89,15 +89,14 @@ class GraphQLEditor extends React.PureComponent {
schemaIsFetching: false schemaIsFetching: false
}; };
let request: RenderedRequest; let request: RenderedRequest | null = null;
try { try {
request = await getRenderedRequest(rawRequest, environmentId); request = await getRenderedRequest(rawRequest, environmentId);
} catch (err) { } catch (err) {
newState.schemaFetchError = `Failed to fetch schema: ${err}`; newState.schemaFetchError = `Failed to fetch schema: ${err}`;
this.setState(newState);
return;
} }
if (request) {
try { try {
// TODO: Use Insomnia's network stack to handle things like authentication // TODO: Use Insomnia's network stack to handle things like authentication
const bodyJson = JSON.stringify({query: introspectionQuery}); const bodyJson = JSON.stringify({query: introspectionQuery});
@ -135,6 +134,7 @@ class GraphQLEditor extends React.PureComponent {
console.warn(`Failed to fetch GraphQL schema from ${request.url}`, err); console.warn(`Failed to fetch GraphQL schema from ${request.url}`, err);
newState.schemaFetchError = `Failed to contact "${request.url}" to fetch schema`; newState.schemaFetchError = `Failed to contact "${request.url}" to fetch schema`;
} }
}
if (this._isMounted) { if (this._isMounted) {
this.setState(newState); this.setState(newState);