@@ -123,6 +123,7 @@ export interface State {
123123 tracingSupported ?: boolean
124124 queryVariablesActive : boolean
125125 endpointUnreachable : boolean
126+ isReloadingSchema : boolean
126127}
127128
128129export interface SimpleProps {
@@ -138,7 +139,7 @@ export interface ToolbarButtonProps extends SimpleProps {
138139export class GraphQLEditor extends React . PureComponent <
139140 Props & LocalThemeInterface & ReduxProps ,
140141 State
141- > {
142+ > {
142143 static Logo : ( props : SimpleProps ) => JSX . Element
143144 static Toolbar : ( props : SimpleProps ) => JSX . Element
144145 static Footer : ( props : SimpleProps ) => JSX . Element
@@ -190,10 +191,10 @@ export class GraphQLEditor extends React.PureComponent<
190191 props . storage || typeof window !== 'undefined'
191192 ? window . localStorage
192193 : {
193- setItem : ( ) => null ,
194- removeItem : ( ) => null ,
195- getItem : ( ) => null ,
196- }
194+ setItem : ( ) => null ,
195+ removeItem : ( ) => null ,
196+ getItem : ( ) => null ,
197+ }
197198
198199 // Determine the initial query to display.
199200 const query =
@@ -217,10 +218,10 @@ export class GraphQLEditor extends React.PureComponent<
217218 props . operationName !== undefined
218219 ? props . operationName
219220 : getSelectedOperationName (
220- null ,
221- this . storageGet ( 'operationName' ) ,
222- queryFacts && queryFacts . operations ,
223- )
221+ null ,
222+ this . storageGet ( 'operationName' ) ,
223+ queryFacts && queryFacts . operations ,
224+ )
224225
225226 let queryVariablesActive = this . storageGet ( 'queryVariablesActive' )
226227 queryVariablesActive =
@@ -253,6 +254,7 @@ export class GraphQLEditor extends React.PureComponent<
253254 selectedVariableNames : [ ] ,
254255 queryVariablesActive,
255256 endpointUnreachable : false ,
257+ isReloadingSchema : false ,
256258 ...queryFacts ,
257259 }
258260
@@ -272,7 +274,7 @@ export class GraphQLEditor extends React.PureComponent<
272274
273275 // Utility for keeping CodeMirror correctly sized.
274276 this . codeMirrorSizer = new CodeMirrorSizer ( )
275- ; ( global as any ) . g = this
277+ ; ( global as any ) . g = this
276278 }
277279
278280 componentWillReceiveProps ( nextProps ) {
@@ -503,6 +505,7 @@ export class GraphQLEditor extends React.PureComponent<
503505 onClickShare = { this . props . onClickShare }
504506 sharing = { this . props . sharing }
505507 onReloadSchema = { this . reloadSchema }
508+ isReloadingSchema = { this . state . isReloadingSchema }
506509 fixedEndpoint = { this . props . fixedEndpoint }
507510 endpointUnreachable = { this . state . endpointUnreachable }
508511 />
@@ -564,13 +567,13 @@ export class GraphQLEditor extends React.PureComponent<
564567 onRunQuery = { this . handleEditorRunQuery }
565568 />
566569 ) : (
567- < VariableEditor
568- ref = { this . setVariableEditorComponent }
569- value = { this . props . session . headers }
570- onEdit = { this . props . onChangeHeaders }
571- onRunQuery = { this . handleEditorRunQuery }
572- />
573- ) }
570+ < VariableEditor
571+ ref = { this . setVariableEditorComponent }
572+ value = { this . props . session . headers }
573+ onEdit = { this . props . onChangeHeaders }
574+ onRunQuery = { this . handleEditorRunQuery }
575+ />
576+ ) }
574577 </ div >
575578 < QueryDragBar ref = { this . setQueryResizer } />
576579 </ div >
@@ -667,7 +670,7 @@ export class GraphQLEditor extends React.PureComponent<
667670 . join ( ' ' )
668671 return `curl '${
669672 this . props . session . endpoint
670- } ' ${ headersString } --data-binary '${ data } ' --compressed`
673+ } ' ${ headersString } --data-binary '${ data } ' --compressed`
671674 }
672675
673676 setQueryVariablesRef = ref => {
@@ -757,14 +760,26 @@ export class GraphQLEditor extends React.PureComponent<
757760 // Private methods
758761
759762 public reloadSchema = async ( ) => {
760- const result = await this . props . schemaFetcher . refetch (
761- this . props . session . endpoint || this . props . endpoint ,
762- this . convertHeaders ( this . props . session . headers ) ,
763- )
764- if ( result ) {
765- const { schema } = result
766- this . setState ( { schema } )
767- this . renewStacks ( schema )
763+ try {
764+ this . setState ( { isReloadingSchema : true } )
765+ const result = await this . props . schemaFetcher . refetch (
766+ this . props . session . endpoint || this . props . endpoint ,
767+ this . convertHeaders ( this . props . session . headers ) ,
768+ )
769+ if ( result ) {
770+ const { schema } = result
771+ this . setState ( {
772+ schema,
773+ isReloadingSchema : false ,
774+ endpointUnreachable : false ,
775+ } )
776+ this . renewStacks ( schema )
777+ }
778+ } catch ( e ) {
779+ this . setState ( {
780+ isReloadingSchema : false ,
781+ endpointUnreachable : true ,
782+ } )
768783 }
769784 }
770785
@@ -799,9 +814,9 @@ export class GraphQLEditor extends React.PureComponent<
799814
800815 this . props . schemaFetcher
801816 . fetch (
802- this . props . session . endpoint || this . props . endpoint ,
803- this . convertHeaders ( this . props . session . headers ) ,
804- )
817+ this . props . session . endpoint || this . props . endpoint ,
818+ this . convertHeaders ( this . props . session . headers ) ,
819+ )
805820 . then ( result => {
806821 if ( result ) {
807822 const { schema, tracingSupported } = result
@@ -1290,11 +1305,11 @@ const DragBar = styled.div`
12901305 cursor: col-resize;
12911306`
12921307
1293- const QueryDragBar = styled ( DragBar ) `
1308+ const QueryDragBar = styled ( DragBar ) `
12941309 right: 0px;
12951310`
12961311
1297- const ResultDragBar = styled ( DragBar ) `
1312+ const ResultDragBar = styled ( DragBar ) `
12981313 left: 0px;
12991314 z-index: 1;
13001315`
0 commit comments