File tree Expand file tree Collapse file tree 2 files changed +22
-21
lines changed Expand file tree Collapse file tree 2 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -534,25 +534,12 @@ export function makeResponse(
534
534
| Readonly < GraphQLError > ,
535
535
acceptedMediaType : AcceptableMediaType ,
536
536
) : Response {
537
- if ( ! ( 'data' in resultOrErrors ) ) {
537
+ if ( isExecutionResult ( resultOrErrors ) ) {
538
538
return [
539
- JSON . stringify ( {
540
- errors : Array . isArray ( resultOrErrors )
541
- ? isObject ( resultOrErrors )
542
- ? resultOrErrors
543
- : new GraphQLError ( String ( resultOrErrors ) )
544
- : [ resultOrErrors ] ,
545
- } ) ,
539
+ JSON . stringify ( resultOrErrors ) ,
546
540
{
547
- ...( acceptedMediaType === 'application/json'
548
- ? {
549
- status : 200 ,
550
- statusText : 'OK' ,
551
- }
552
- : {
553
- status : 400 ,
554
- statusText : 'Bad Request' ,
555
- } ) ,
541
+ status : 200 ,
542
+ statusText : 'OK' ,
556
543
headers : {
557
544
'content-type' :
558
545
acceptedMediaType === 'application/json'
@@ -564,10 +551,23 @@ export function makeResponse(
564
551
}
565
552
566
553
return [
567
- JSON . stringify ( resultOrErrors ) ,
554
+ JSON . stringify ( {
555
+ errors : Array . isArray ( resultOrErrors )
556
+ ? isObject ( resultOrErrors )
557
+ ? resultOrErrors
558
+ : new GraphQLError ( String ( resultOrErrors ) )
559
+ : [ resultOrErrors ] ,
560
+ } ) ,
568
561
{
569
- status : 200 ,
570
- statusText : 'OK' ,
562
+ ...( acceptedMediaType === 'application/json'
563
+ ? {
564
+ status : 200 ,
565
+ statusText : 'OK' ,
566
+ }
567
+ : {
568
+ status : 400 ,
569
+ statusText : 'Bad Request' ,
570
+ } ) ,
571
571
headers : {
572
572
'content-type' :
573
573
acceptedMediaType === 'application/json'
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ export function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[] {
25
25
/** @private */
26
26
export function isExecutionResult ( val : unknown ) : val is ExecutionResult {
27
27
return (
28
- isObject ( val ) && ( 'data' in val || 'errors' in val || 'extensions' in val )
28
+ isObject ( val ) &&
29
+ ( 'data' in val || ( 'data' in val && val . data == null && 'errors' in val ) )
29
30
) ;
30
31
}
31
32
You can’t perform that action at this time.
0 commit comments