File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
packages/graphql-playground-react/src/state/sessions Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ function* runQuerySaga(action) {
176
176
try {
177
177
while ( true ) {
178
178
const { value, error } = yield take ( channel )
179
- if ( value . extensions ) {
179
+ if ( value && value . extensions ) {
180
180
const extensions = value . extensions
181
181
yield put ( setResponseExtensions ( extensions ) )
182
182
delete value . extensiosn
@@ -195,17 +195,23 @@ function* runQuerySaga(action) {
195
195
}
196
196
}
197
197
198
- function formatError ( error ) {
198
+ export function formatError ( error , fetchingSchema : boolean = false ) {
199
+ const message = extractMessage ( error )
200
+ if ( message === 'Failed to fetch' ) {
201
+ const schemaMessage = fetchingSchema ? ' schema' : ''
202
+ return { error : `${ message } ${ schemaMessage } . Please check your connection` }
203
+ }
204
+
205
+ return { error : message }
206
+ }
207
+
208
+ function extractMessage ( error ) {
199
209
if ( error instanceof Error ) {
200
- return {
201
- error : error . message ,
202
- }
210
+ return error . message
203
211
}
204
212
205
213
if ( typeof error === 'string' ) {
206
- return {
207
- error,
208
- }
214
+ return error
209
215
}
210
216
211
217
return error
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
25
25
import { getSelectedSessionId } from './selectors'
26
26
import { getDefaultSession , defaultQuery } from '../../constants'
27
27
import * as cuid from 'cuid'
28
+ import { formatError } from './fetchingSagas'
28
29
29
30
export interface SessionStateProps {
30
31
sessions : OrderedMap < string , Session >
@@ -308,7 +309,11 @@ const reducer = handleActions(
308
309
responses : List ( [
309
310
new ResponseRecord ( {
310
311
resultID : cuid ( ) ,
311
- date : payload . error ,
312
+ date : JSON . stringify (
313
+ formatError ( payload . error , true ) ,
314
+ null ,
315
+ 2 ,
316
+ ) ,
312
317
time : new Date ( ) ,
313
318
} ) ,
314
319
] ) ,
You can’t perform that action at this time.
0 commit comments