@@ -754,15 +754,15 @@ function executeField(
754
754
return completed . then ( undefined , ( rawError ) => {
755
755
const error = locatedError ( rawError , fieldNodes , pathToArray ( path ) ) ;
756
756
const handledError = handleFieldError ( error , returnType , errors ) ;
757
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
757
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
758
758
return handledError ;
759
759
} ) ;
760
760
}
761
761
return completed ;
762
762
} catch ( rawError ) {
763
763
const error = locatedError ( rawError , fieldNodes , pathToArray ( path ) ) ;
764
764
const handledError = handleFieldError ( error , returnType , errors ) ;
765
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
765
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
766
766
return handledError ;
767
767
}
768
768
}
@@ -952,7 +952,7 @@ async function completePromisedValue(
952
952
const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
953
953
const error = locatedError ( rawError , fieldNodes , pathToArray ( path ) ) ;
954
954
const handledError = handleFieldError ( error , returnType , errors ) ;
955
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
955
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
956
956
return handledError ;
957
957
}
958
958
}
@@ -1233,10 +1233,7 @@ function completeListItemValue(
1233
1233
pathToArray ( itemPath ) ,
1234
1234
) ;
1235
1235
const handledError = handleFieldError ( error , itemType , errors ) ;
1236
- exeContext . publisher . filterSubsequentPayloads (
1237
- itemPath ,
1238
- asyncPayloadRecord ,
1239
- ) ;
1236
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1240
1237
return handledError ;
1241
1238
} ) ,
1242
1239
) ;
@@ -1248,7 +1245,7 @@ function completeListItemValue(
1248
1245
} catch ( rawError ) {
1249
1246
const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1250
1247
const handledError = handleFieldError ( error , itemType , errors ) ;
1251
- exeContext . publisher . filterSubsequentPayloads ( itemPath , asyncPayloadRecord ) ;
1248
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1252
1249
completedResults . push ( handledError ) ;
1253
1250
}
1254
1251
@@ -1846,7 +1843,7 @@ function executeStreamField(
1846
1843
( value ) => asyncPayloadRecord . addItems ( [ value ] ) ,
1847
1844
( error ) => {
1848
1845
asyncPayloadRecord . errors . push ( error ) ;
1849
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1846
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1850
1847
asyncPayloadRecord . addItems ( null ) ;
1851
1848
} ,
1852
1849
) ;
@@ -1873,14 +1870,11 @@ function executeStreamField(
1873
1870
itemType ,
1874
1871
asyncPayloadRecord . errors ,
1875
1872
) ;
1876
- exeContext . publisher . filterSubsequentPayloads (
1877
- itemPath ,
1878
- asyncPayloadRecord ,
1879
- ) ;
1873
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1880
1874
}
1881
1875
} catch ( error ) {
1882
1876
asyncPayloadRecord . errors . push ( error ) ;
1883
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
1877
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1884
1878
asyncPayloadRecord . addItems ( null ) ;
1885
1879
return asyncPayloadRecord ;
1886
1880
}
@@ -1894,20 +1888,14 @@ function executeStreamField(
1894
1888
itemType ,
1895
1889
asyncPayloadRecord . errors ,
1896
1890
) ;
1897
- exeContext . publisher . filterSubsequentPayloads (
1898
- itemPath ,
1899
- asyncPayloadRecord ,
1900
- ) ;
1891
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1901
1892
return handledError ;
1902
1893
} )
1903
1894
. then (
1904
1895
( value ) => asyncPayloadRecord . addItems ( [ value ] ) ,
1905
1896
( error ) => {
1906
1897
asyncPayloadRecord . errors . push ( error ) ;
1907
- exeContext . publisher . filterSubsequentPayloads (
1908
- path ,
1909
- asyncPayloadRecord ,
1910
- ) ;
1898
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
1911
1899
asyncPayloadRecord . addItems ( null ) ;
1912
1900
} ,
1913
1901
) ;
@@ -1962,18 +1950,15 @@ async function executeStreamIteratorItem(
1962
1950
itemType ,
1963
1951
asyncPayloadRecord . errors ,
1964
1952
) ;
1965
- exeContext . publisher . filterSubsequentPayloads (
1966
- itemPath ,
1967
- asyncPayloadRecord ,
1968
- ) ;
1953
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1969
1954
return handledError ;
1970
1955
} ) ;
1971
1956
}
1972
1957
return { done : false , value : completedItem } ;
1973
1958
} catch ( rawError ) {
1974
1959
const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1975
1960
const value = handleFieldError ( error , itemType , asyncPayloadRecord . errors ) ;
1976
- exeContext . publisher . filterSubsequentPayloads ( itemPath , asyncPayloadRecord ) ;
1961
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1977
1962
return { done : false , value } ;
1978
1963
}
1979
1964
}
@@ -2016,7 +2001,7 @@ async function executeStreamIterator(
2016
2001
) ;
2017
2002
} catch ( error ) {
2018
2003
asyncPayloadRecord . errors . push ( error ) ;
2019
- exeContext . publisher . filterSubsequentPayloads ( path , asyncPayloadRecord ) ;
2004
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2020
2005
asyncPayloadRecord . addItems ( null ) ;
2021
2006
// entire stream has errored and bubbled upwards
2022
2007
if ( iterator ?. return ) {
@@ -2034,10 +2019,7 @@ async function executeStreamIterator(
2034
2019
( resolvedItem ) => asyncPayloadRecord . addItems ( [ resolvedItem ] ) ,
2035
2020
( error ) => {
2036
2021
asyncPayloadRecord . errors . push ( error ) ;
2037
- exeContext . publisher . filterSubsequentPayloads (
2038
- path ,
2039
- asyncPayloadRecord ,
2040
- ) ;
2022
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
2041
2023
asyncPayloadRecord . addItems ( null ) ;
2042
2024
} ,
2043
2025
) ;
@@ -2053,6 +2035,28 @@ async function executeStreamIterator(
2053
2035
}
2054
2036
}
2055
2037
2038
+ function filterSubsequentPayloads (
2039
+ exeContext : ExecutionContext ,
2040
+ nullPath : Path ,
2041
+ currentAsyncRecord : AsyncPayloadRecord | undefined ,
2042
+ ) : void {
2043
+ const nullPathArray = pathToArray ( nullPath ) ;
2044
+ exeContext . publisher . filter ( ( asyncRecord ) => {
2045
+ if ( asyncRecord === currentAsyncRecord ) {
2046
+ // don't remove payload from where error originates
2047
+ return true ;
2048
+ }
2049
+ for ( let i = 0 ; i < nullPathArray . length ; i ++ ) {
2050
+ if ( asyncRecord . path [ i ] !== nullPathArray [ i ] ) {
2051
+ // asyncRecord points to a path unaffected by this payload
2052
+ return true ;
2053
+ }
2054
+ }
2055
+
2056
+ return false ;
2057
+ } ) ;
2058
+ }
2059
+
2056
2060
class DeferredFragmentRecord {
2057
2061
type : 'defer' ;
2058
2062
errors : Array < GraphQLError > ;
0 commit comments