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) {
176176 try {
177177 while ( true ) {
178178 const { value, error } = yield take ( channel )
179- if ( value . extensions ) {
179+ if ( value && value . extensions ) {
180180 const extensions = value . extensions
181181 yield put ( setResponseExtensions ( extensions ) )
182182 delete value . extensiosn
@@ -195,17 +195,23 @@ function* runQuerySaga(action) {
195195 }
196196}
197197
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 ) {
199209 if ( error instanceof Error ) {
200- return {
201- error : error . message ,
202- }
210+ return error . message
203211 }
204212
205213 if ( typeof error === 'string' ) {
206- return {
207- error,
208- }
214+ return error
209215 }
210216
211217 return error
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
2525import { getSelectedSessionId } from './selectors'
2626import { getDefaultSession , defaultQuery } from '../../constants'
2727import * as cuid from 'cuid'
28+ import { formatError } from './fetchingSagas'
2829
2930export interface SessionStateProps {
3031 sessions : OrderedMap < string , Session >
@@ -308,7 +309,11 @@ const reducer = handleActions(
308309 responses : List ( [
309310 new ResponseRecord ( {
310311 resultID : cuid ( ) ,
311- date : payload . error ,
312+ date : JSON . stringify (
313+ formatError ( payload . error , true ) ,
314+ null ,
315+ 2 ,
316+ ) ,
312317 time : new Date ( ) ,
313318 } ) ,
314319 ] ) ,
You can’t perform that action at this time.
0 commit comments