File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,56 @@ async def asyncReturnErrorWithExtensions(self, _info):
514
514
],
515
515
)
516
516
517
+ def handles_sync_errors_combined_with_async_ones ():
518
+ is_async_resolver_finished = False
519
+
520
+ async def async_resolver (_obj , _info ):
521
+ nonlocal is_async_resolver_finished
522
+ sleep = asyncio .sleep
523
+ sleep (0 )
524
+ sleep (0 )
525
+ sleep (0 )
526
+ is_async_resolver_finished = True
527
+
528
+ schema = GraphQLSchema (
529
+ GraphQLObjectType (
530
+ "Query" ,
531
+ {
532
+ "syncNullError" : GraphQLField (
533
+ GraphQLNonNull (GraphQLString ), resolve = lambda _obj , _info : None
534
+ ),
535
+ "asyncNullError" : GraphQLField (
536
+ GraphQLNonNull (GraphQLString ), resolve = async_resolver
537
+ ),
538
+ },
539
+ )
540
+ )
541
+
542
+ document = parse (
543
+ """
544
+ {
545
+ asyncNullError
546
+ syncNullError
547
+ }
548
+ """
549
+ )
550
+
551
+ result = execute (schema , document )
552
+
553
+ assert is_async_resolver_finished is False
554
+
555
+ assert result == (
556
+ None ,
557
+ [
558
+ {
559
+ "message" : "Cannot return null"
560
+ " for non-nullable field Query.syncNullError." ,
561
+ "locations" : [(4 , 15 )],
562
+ "path" : ["syncNullError" ],
563
+ }
564
+ ],
565
+ )
566
+
517
567
def full_response_path_is_included_for_non_nullable_fields ():
518
568
def resolve_ok (* _args ):
519
569
return {}
You can’t perform that action at this time.
0 commit comments