@@ -123,6 +123,7 @@ export interface State {
123
123
tracingSupported ?: boolean
124
124
queryVariablesActive : boolean
125
125
endpointUnreachable : boolean
126
+ isReloadingSchema : boolean
126
127
}
127
128
128
129
export interface SimpleProps {
@@ -138,7 +139,7 @@ export interface ToolbarButtonProps extends SimpleProps {
138
139
export class GraphQLEditor extends React . PureComponent <
139
140
Props & LocalThemeInterface & ReduxProps ,
140
141
State
141
- > {
142
+ > {
142
143
static Logo : ( props : SimpleProps ) => JSX . Element
143
144
static Toolbar : ( props : SimpleProps ) => JSX . Element
144
145
static Footer : ( props : SimpleProps ) => JSX . Element
@@ -190,10 +191,10 @@ export class GraphQLEditor extends React.PureComponent<
190
191
props . storage || typeof window !== 'undefined'
191
192
? window . localStorage
192
193
: {
193
- setItem : ( ) => null ,
194
- removeItem : ( ) => null ,
195
- getItem : ( ) => null ,
196
- }
194
+ setItem : ( ) => null ,
195
+ removeItem : ( ) => null ,
196
+ getItem : ( ) => null ,
197
+ }
197
198
198
199
// Determine the initial query to display.
199
200
const query =
@@ -217,10 +218,10 @@ export class GraphQLEditor extends React.PureComponent<
217
218
props . operationName !== undefined
218
219
? props . operationName
219
220
: getSelectedOperationName (
220
- null ,
221
- this . storageGet ( 'operationName' ) ,
222
- queryFacts && queryFacts . operations ,
223
- )
221
+ null ,
222
+ this . storageGet ( 'operationName' ) ,
223
+ queryFacts && queryFacts . operations ,
224
+ )
224
225
225
226
let queryVariablesActive = this . storageGet ( 'queryVariablesActive' )
226
227
queryVariablesActive =
@@ -253,6 +254,7 @@ export class GraphQLEditor extends React.PureComponent<
253
254
selectedVariableNames : [ ] ,
254
255
queryVariablesActive,
255
256
endpointUnreachable : false ,
257
+ isReloadingSchema : false ,
256
258
...queryFacts ,
257
259
}
258
260
@@ -272,7 +274,7 @@ export class GraphQLEditor extends React.PureComponent<
272
274
273
275
// Utility for keeping CodeMirror correctly sized.
274
276
this . codeMirrorSizer = new CodeMirrorSizer ( )
275
- ; ( global as any ) . g = this
277
+ ; ( global as any ) . g = this
276
278
}
277
279
278
280
componentWillReceiveProps ( nextProps ) {
@@ -503,6 +505,7 @@ export class GraphQLEditor extends React.PureComponent<
503
505
onClickShare = { this . props . onClickShare }
504
506
sharing = { this . props . sharing }
505
507
onReloadSchema = { this . reloadSchema }
508
+ isReloadingSchema = { this . state . isReloadingSchema }
506
509
fixedEndpoint = { this . props . fixedEndpoint }
507
510
endpointUnreachable = { this . state . endpointUnreachable }
508
511
/>
@@ -564,13 +567,13 @@ export class GraphQLEditor extends React.PureComponent<
564
567
onRunQuery = { this . handleEditorRunQuery }
565
568
/>
566
569
) : (
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
+ ) }
574
577
</ div >
575
578
< QueryDragBar ref = { this . setQueryResizer } />
576
579
</ div >
@@ -667,7 +670,7 @@ export class GraphQLEditor extends React.PureComponent<
667
670
. join ( ' ' )
668
671
return `curl '${
669
672
this . props . session . endpoint
670
- } ' ${ headersString } --data-binary '${ data } ' --compressed`
673
+ } ' ${ headersString } --data-binary '${ data } ' --compressed`
671
674
}
672
675
673
676
setQueryVariablesRef = ref => {
@@ -757,14 +760,26 @@ export class GraphQLEditor extends React.PureComponent<
757
760
// Private methods
758
761
759
762
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
+ } )
768
783
}
769
784
}
770
785
@@ -799,9 +814,9 @@ export class GraphQLEditor extends React.PureComponent<
799
814
800
815
this . props . schemaFetcher
801
816
. 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
+ )
805
820
. then ( result => {
806
821
if ( result ) {
807
822
const { schema, tracingSupported } = result
@@ -1290,11 +1305,11 @@ const DragBar = styled.div`
1290
1305
cursor: col-resize;
1291
1306
`
1292
1307
1293
- const QueryDragBar = styled ( DragBar ) `
1308
+ const QueryDragBar = styled ( DragBar ) `
1294
1309
right: 0px;
1295
1310
`
1296
1311
1297
- const ResultDragBar = styled ( DragBar ) `
1312
+ const ResultDragBar = styled ( DragBar ) `
1298
1313
left: 0px;
1299
1314
z-index: 1;
1300
1315
`
0 commit comments