File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -632,6 +632,57 @@ describe('Execute: Handles basic execution tasks', () => {
632632 expect ( isAsyncResolverFinished ) . to . equal ( true ) ;
633633 } ) ;
634634
635+ it ( 'handles async bubbling errors combined with non-bubbling errors' , async ( ) => {
636+ const schema = new GraphQLSchema ( {
637+ query : new GraphQLObjectType ( {
638+ name : 'Query' ,
639+ fields : {
640+ asyncNonNullError : {
641+ type : new GraphQLNonNull ( GraphQLString ) ,
642+ async resolve ( ) {
643+ await resolveOnNextTick ( ) ;
644+ return null ;
645+ } ,
646+ } ,
647+ asyncError : {
648+ type : GraphQLString ,
649+ async resolve ( ) {
650+ await resolveOnNextTick ( ) ;
651+ throw new Error ( 'Oops' ) ;
652+ } ,
653+ } ,
654+ } ,
655+ } ) ,
656+ } ) ;
657+
658+ // Order is important here, as the nullable error should resolve first
659+ const document = parse ( `
660+ {
661+ asyncError
662+ asyncNonNullError
663+ }
664+ ` ) ;
665+
666+ const result = execute ( { schema, document } ) ;
667+
668+ expectJSON ( await result ) . toDeepEqual ( {
669+ data : null ,
670+ errors : [
671+ {
672+ message : 'Oops' ,
673+ locations : [ { line : 3 , column : 9 } ] ,
674+ path : [ 'asyncError' ] ,
675+ } ,
676+ {
677+ message :
678+ 'Cannot return null for non-nullable field Query.asyncNonNullError.' ,
679+ locations : [ { line : 4 , column : 9 } ] ,
680+ path : [ 'asyncNonNullError' ] ,
681+ } ,
682+ ] ,
683+ } ) ;
684+ } ) ;
685+
635686 it ( 'Full response path is included for non-nullable fields' , ( ) => {
636687 const A : GraphQLObjectType = new GraphQLObjectType ( {
637688 name : 'A' ,
You can’t perform that action at this time.
0 commit comments