@@ -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
@@ -1929,10 +1926,7 @@ function executeStreamField(
1929
1926
itemType ,
1930
1927
asyncPayloadRecord . errors ,
1931
1928
) ;
1932
- exeContext . publisher . filterSubsequentPayloads (
1933
- itemPath ,
1934
- asyncPayloadRecord ,
1935
- ) ;
1929
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1936
1930
return handledError ;
1937
1931
} ) ;
1938
1932
}
@@ -1943,14 +1937,11 @@ function executeStreamField(
1943
1937
itemType ,
1944
1938
asyncPayloadRecord . errors ,
1945
1939
) ;
1946
- exeContext . publisher . filterSubsequentPayloads (
1947
- itemPath ,
1948
- asyncPayloadRecord ,
1949
- ) ;
1940
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1950
1941
}
1951
1942
} catch ( error ) {
1952
1943
asyncPayloadRecord . errors . push ( error ) ;
1953
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1944
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1954
1945
asyncPayloadRecord . addItems ( null ) ;
1955
1946
return asyncPayloadRecord ;
1956
1947
}
@@ -1960,7 +1951,7 @@ function executeStreamField(
1960
1951
( resolvedItem ) => asyncPayloadRecord . addItems ( [ resolvedItem ] ) ,
1961
1952
( error ) => {
1962
1953
asyncPayloadRecord . errors . push ( error ) ;
1963
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1954
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1964
1955
asyncPayloadRecord . addItems ( null ) ;
1965
1956
} ,
1966
1957
) ;
@@ -2014,18 +2005,15 @@ async function executeStreamIteratorItem(
2014
2005
itemType ,
2015
2006
asyncPayloadRecord . errors ,
2016
2007
) ;
2017
- exeContext . publisher . filterSubsequentPayloads (
2018
- itemPath ,
2019
- asyncPayloadRecord ,
2020
- ) ;
2008
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
2021
2009
return handledError ;
2022
2010
} ) ;
2023
2011
}
2024
2012
return { done : false , value : completedItem } ;
2025
2013
} catch ( rawError ) {
2026
2014
const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
2027
2015
const value = handleFieldError ( error , itemType , asyncPayloadRecord . errors ) ;
2028
- exeContext . publisher . filterSubsequentPayloads ( itemPath , asyncPayloadRecord ) ;
2016
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
2029
2017
return { done : false , value } ;
2030
2018
}
2031
2019
}
@@ -2068,7 +2056,7 @@ async function executeStreamIterator(
2068
2056
) ;
2069
2057
} catch ( error ) {
2070
2058
asyncPayloadRecord . errors . push ( error ) ;
2071
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
2059
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2072
2060
asyncPayloadRecord . addItems ( null ) ;
2073
2061
// entire stream has errored and bubbled upwards
2074
2062
if ( iterator ?. return ) {
@@ -2086,10 +2074,7 @@ async function executeStreamIterator(
2086
2074
( resolvedItem ) => asyncPayloadRecord . addItems ( [ resolvedItem ] ) ,
2087
2075
( error ) => {
2088
2076
asyncPayloadRecord . errors . push ( error ) ;
2089
- exeContext . publisher . filterSubsequentPayloads (
2090
- path ,
2091
- asyncPayloadRecord ,
2092
- ) ;
2077
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2093
2078
asyncPayloadRecord . addItems ( null ) ;
2094
2079
} ,
2095
2080
) ;
@@ -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