@@ -1068,7 +1068,8 @@ export class GraphiQL extends React.Component<GraphiQLProps, GraphiQLState> {
10681068 ) ;
10691069 }
10701070
1071- const totalResponse : FetcherResultPayload = { data : { } } ;
1071+ // when dealing with defer or stream, we need to aggregate results
1072+ const fullResponse : FetcherResultPayload = { data : { } , hasNext : false } ;
10721073
10731074 // _fetchQuery may return a subscription.
10741075 const subscription = await this . _fetchQuery (
@@ -1080,36 +1081,36 @@ export class GraphiQL extends React.Component<GraphiQLProps, GraphiQLState> {
10801081 ( result : FetcherResult ) => {
10811082 if ( queryID === this . _editorQueryID ) {
10821083 if (
1083- typeof result === 'object ' &&
1084+ typeof result !== 'string ' &&
10841085 result !== null &&
10851086 'hasNext' in result
10861087 ) {
10871088 if ( result . errors ) {
10881089 // We dont care about "index" here, just concat.
1089- totalResponse . errors = [
1090- ...( totalResponse ?. errors || [ ] ) ,
1090+ fullResponse . errors = [
1091+ ...( fullResponse ?. errors || [ ] ) ,
10911092 ...result ?. errors ,
10921093 ] ;
10931094 }
10941095
1095- totalResponse . hasNext = result . hasNext ;
1096+ fullResponse . hasNext = result . hasNext ;
10961097
10971098 if ( 'path' in result ) {
10981099 if ( ! ( 'data' in result ) ) {
10991100 throw new Error (
11001101 `Expected part to contain a data property, but got ${ result } ` ,
11011102 ) ;
11021103 }
1103- dset ( totalResponse . data , result . path ! . map ( String ) , result . data ) ;
1104+ dset ( fullResponse . data , result . path , result . data ) ;
11041105 } else if ( 'data' in result ) {
11051106 // If there is no path, we don't know what to do with the payload,
11061107 // so we just set it.
1107- totalResponse . data = result . data ;
1108+ fullResponse . data = result . data ;
11081109 }
11091110
11101111 this . setState ( {
11111112 isWaitingForResponse : false ,
1112- response : GraphiQL . formatResult ( totalResponse ) ,
1113+ response : GraphiQL . formatResult ( fullResponse ) ,
11131114 } ) ;
11141115 } else {
11151116 this . setState ( {
0 commit comments