@@ -748,15 +748,15 @@ function executeField(
748
748
return completed . then ( undefined , ( rawError ) => {
749
749
const error = locatedError ( rawError , fieldNodes , pathToArray ( path ) ) ;
750
750
const handledError = handleFieldError ( error , returnType , errors ) ;
751
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
751
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
752
752
return handledError ;
753
753
} ) ;
754
754
}
755
755
return completed ;
756
756
} catch ( rawError ) {
757
757
const error = locatedError ( rawError , fieldNodes , pathToArray ( path ) ) ;
758
758
const handledError = handleFieldError ( error , returnType , errors ) ;
759
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
759
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
760
760
return handledError ;
761
761
}
762
762
}
@@ -1188,10 +1188,7 @@ function completeListItemValue(
1188
1188
pathToArray ( itemPath ) ,
1189
1189
) ;
1190
1190
const handledError = handleFieldError ( error , itemType , errors ) ;
1191
- exeContext . publisher . filterSubsequentPayloads (
1192
- itemPath ,
1193
- asyncPayloadRecord ,
1194
- ) ;
1191
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1195
1192
return handledError ;
1196
1193
} ) ,
1197
1194
) ;
@@ -1203,7 +1200,7 @@ function completeListItemValue(
1203
1200
} catch ( rawError ) {
1204
1201
const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1205
1202
const handledError = handleFieldError ( error , itemType , errors ) ;
1206
- exeContext . publisher . filterSubsequentPayloads ( itemPath , asyncPayloadRecord ) ;
1203
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1207
1204
completedResults . push ( handledError ) ;
1208
1205
}
1209
1206
@@ -1924,10 +1921,7 @@ function executeStreamField(
1924
1921
itemType ,
1925
1922
asyncPayloadRecord . errors ,
1926
1923
) ;
1927
- exeContext . publisher . filterSubsequentPayloads (
1928
- itemPath ,
1929
- asyncPayloadRecord ,
1930
- ) ;
1924
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1931
1925
return handledError ;
1932
1926
} ) ;
1933
1927
}
@@ -1938,14 +1932,11 @@ function executeStreamField(
1938
1932
itemType ,
1939
1933
asyncPayloadRecord . errors ,
1940
1934
) ;
1941
- exeContext . publisher . filterSubsequentPayloads (
1942
- itemPath ,
1943
- asyncPayloadRecord ,
1944
- ) ;
1935
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1945
1936
}
1946
1937
} catch ( error ) {
1947
1938
asyncPayloadRecord . errors . push ( error ) ;
1948
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1939
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1949
1940
asyncPayloadRecord . addItems ( null ) ;
1950
1941
return asyncPayloadRecord ;
1951
1942
}
@@ -1956,7 +1947,7 @@ function executeStreamField(
1956
1947
( value ) => [ value ] ,
1957
1948
( error ) => {
1958
1949
asyncPayloadRecord . errors . push ( error ) ;
1959
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1950
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1960
1951
return null ;
1961
1952
} ,
1962
1953
) ;
@@ -2011,18 +2002,15 @@ async function executeStreamIteratorItem(
2011
2002
itemType ,
2012
2003
asyncPayloadRecord . errors ,
2013
2004
) ;
2014
- exeContext . publisher . filterSubsequentPayloads (
2015
- itemPath ,
2016
- asyncPayloadRecord ,
2017
- ) ;
2005
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
2018
2006
return handledError ;
2019
2007
} ) ;
2020
2008
}
2021
2009
return { done : false , value : completedItem } ;
2022
2010
} catch ( rawError ) {
2023
2011
const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
2024
2012
const value = handleFieldError ( error , itemType , asyncPayloadRecord . errors ) ;
2025
- exeContext . publisher . filterSubsequentPayloads ( itemPath , asyncPayloadRecord ) ;
2013
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
2026
2014
return { done : false , value } ;
2027
2015
}
2028
2016
}
@@ -2065,7 +2053,7 @@ async function executeStreamIterator(
2065
2053
) ;
2066
2054
} catch ( error ) {
2067
2055
asyncPayloadRecord . errors . push ( error ) ;
2068
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
2056
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2069
2057
asyncPayloadRecord . addItems ( null ) ;
2070
2058
// entire stream has errored and bubbled upwards
2071
2059
if ( iterator ?. return ) {
@@ -2084,10 +2072,7 @@ async function executeStreamIterator(
2084
2072
( value ) => [ value ] ,
2085
2073
( error ) => {
2086
2074
asyncPayloadRecord . errors . push ( error ) ;
2087
- exeContext . publisher . filterSubsequentPayloads (
2088
- path ,
2089
- asyncPayloadRecord ,
2090
- ) ;
2075
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2091
2076
return null ;
2092
2077
} ,
2093
2078
) ;
@@ -2105,6 +2090,28 @@ async function executeStreamIterator(
2105
2090
}
2106
2091
}
2107
2092
2093
+ function filterSubsequentPayloads (
2094
+ exeContext : ExecutionContext ,
2095
+ nullPath : Path ,
2096
+ currentAsyncRecord : AsyncPayloadRecord | undefined ,
2097
+ ) : void {
2098
+ const nullPathArray = pathToArray ( nullPath ) ;
2099
+ exeContext . publisher . filter ( ( asyncRecord ) => {
2100
+ if ( asyncRecord === currentAsyncRecord ) {
2101
+ // don't remove payload from where error originates
2102
+ return true ;
2103
+ }
2104
+ for ( let i = 0 ; i < nullPathArray . length ; i ++ ) {
2105
+ if ( asyncRecord . path [ i ] !== nullPathArray [ i ] ) {
2106
+ // asyncRecord points to a path unaffected by this payload
2107
+ return true ;
2108
+ }
2109
+ }
2110
+
2111
+ return false ;
2112
+ } ) ;
2113
+ }
2114
+
2108
2115
class DeferredFragmentRecord {
2109
2116
type : 'defer' ;
2110
2117
errors : Array < GraphQLError > ;
0 commit comments