@@ -43,11 +43,11 @@ async def anext(iterator): # noqa: A001
4343
4444
4545class Friend (NamedTuple ):
46- name : str
4746 id : int
47+ name : str
4848
4949
50- friends = [Friend ("Luke" , 1 ), Friend ("Han" , 2 ), Friend ("Leia" , 3 )]
50+ friends = [Friend (1 , "Luke" ), Friend (2 , "Han" ), Friend (3 , "Leia" )]
5151
5252query = GraphQLObjectType (
5353 "Query" ,
@@ -1186,6 +1186,50 @@ async def friend_list(_info):
11861186 },
11871187 }
11881188
1189+ @pytest .mark .asyncio ()
1190+ @pytest .mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
1191+ async def filters_payloads_that_are_nulled_by_a_later_synchronous_error ():
1192+ document = parse (
1193+ """
1194+ query {
1195+ nestedObject {
1196+ nestedFriendList @stream(initialCount: 0) {
1197+ name
1198+ }
1199+ nonNullScalarField
1200+ }
1201+ }
1202+ """
1203+ )
1204+
1205+ async def friend_list (_info ):
1206+ await sleep (0 )
1207+ yield friends [0 ]
1208+
1209+ result = await complete (
1210+ document ,
1211+ {
1212+ "nestedObject" : {
1213+ "nestedFriendList" : friend_list ,
1214+ "nonNullScalarField" : lambda _info : None ,
1215+ }
1216+ },
1217+ )
1218+
1219+ assert result == {
1220+ "errors" : [
1221+ {
1222+ "message" : "Cannot return null for non-nullable field"
1223+ " NestedObject.nonNullScalarField." ,
1224+ "locations" : [{"line" : 7 , "column" : 17 }],
1225+ "path" : ["nestedObject" , "nonNullScalarField" ],
1226+ },
1227+ ],
1228+ "data" : {
1229+ "nestedObject" : None ,
1230+ },
1231+ }
1232+
11891233 @pytest .mark .asyncio ()
11901234 async def does_not_filter_payloads_when_null_error_is_in_a_different_path ():
11911235 document = parse (
0 commit comments