@@ -996,7 +996,7 @@ async function completeAsyncIteratorValue(
996
996
break ;
997
997
}
998
998
999
- const fieldPath = addPath ( path , index , undefined ) ;
999
+ const itemPath = addPath ( path , index , undefined ) ;
1000
1000
try {
1001
1001
// eslint-disable-next-line no-await-in-loop
1002
1002
const { value, done } = await iterator . next ( ) ;
@@ -1011,7 +1011,7 @@ async function completeAsyncIteratorValue(
1011
1011
itemType ,
1012
1012
fieldNodes ,
1013
1013
info ,
1014
- fieldPath ,
1014
+ itemPath ,
1015
1015
value ,
1016
1016
asyncPayloadRecord ,
1017
1017
) ;
@@ -1024,10 +1024,10 @@ async function completeAsyncIteratorValue(
1024
1024
const error = locatedError (
1025
1025
rawError ,
1026
1026
fieldNodes ,
1027
- pathToArray ( fieldPath ) ,
1027
+ pathToArray ( itemPath ) ,
1028
1028
) ;
1029
1029
const handledError = handleFieldError ( error , itemType , errors ) ;
1030
- filterSubsequentPayloads ( exeContext , fieldPath ) ;
1030
+ filterSubsequentPayloads ( exeContext , itemPath ) ;
1031
1031
return handledError ;
1032
1032
} ) ,
1033
1033
) ;
@@ -1036,18 +1036,13 @@ async function completeAsyncIteratorValue(
1036
1036
}
1037
1037
} catch ( rawError ) {
1038
1038
completedResults . push ( null ) ;
1039
- const error = locatedError (
1040
- rawError ,
1041
- fieldNodes ,
1042
- pathToArray ( fieldPath ) ,
1043
- ) ;
1044
- filterSubsequentPayloads ( exeContext , fieldPath ) ;
1039
+ const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1040
+ filterSubsequentPayloads ( exeContext , itemPath ) ;
1045
1041
handleFieldError ( error , itemType , errors ) ;
1046
1042
}
1047
1043
} catch ( rawError ) {
1048
- completedResults . push ( null ) ;
1049
- const error = locatedError ( rawError , fieldNodes , pathToArray ( fieldPath ) ) ;
1050
- handleFieldError ( error , itemType , errors ) ;
1044
+ const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1045
+ completedResults . push ( handleFieldError ( error , itemType , errors ) ) ;
1051
1046
break ;
1052
1047
}
1053
1048
index += 1 ;
@@ -1103,28 +1098,29 @@ function completeListValue(
1103
1098
// No need to modify the info object containing the path,
1104
1099
// since from here on it is not ever accessed by resolver functions.
1105
1100
const itemPath = addPath ( path , index , undefined ) ;
1101
+
1102
+ if (
1103
+ stream &&
1104
+ typeof stream . initialCount === 'number' &&
1105
+ index >= stream . initialCount
1106
+ ) {
1107
+ previousAsyncPayloadRecord = executeStreamField (
1108
+ path ,
1109
+ itemPath ,
1110
+ item ,
1111
+ exeContext ,
1112
+ fieldNodes ,
1113
+ info ,
1114
+ itemType ,
1115
+ stream . label ,
1116
+ previousAsyncPayloadRecord ,
1117
+ ) ;
1118
+ index ++ ;
1119
+ continue ;
1120
+ }
1121
+
1106
1122
try {
1107
1123
let completedItem ;
1108
-
1109
- if (
1110
- stream &&
1111
- typeof stream . initialCount === 'number' &&
1112
- index >= stream . initialCount
1113
- ) {
1114
- previousAsyncPayloadRecord = executeStreamField (
1115
- path ,
1116
- itemPath ,
1117
- item ,
1118
- exeContext ,
1119
- fieldNodes ,
1120
- info ,
1121
- itemType ,
1122
- stream . label ,
1123
- previousAsyncPayloadRecord ,
1124
- ) ;
1125
- index ++ ;
1126
- continue ;
1127
- }
1128
1124
if ( isPromise ( item ) ) {
1129
1125
completedItem = item . then ( ( resolved ) =>
1130
1126
completeValue (
@@ -1939,7 +1935,7 @@ async function executeStreamIteratorItem(
1939
1935
info : GraphQLResolveInfo ,
1940
1936
itemType : GraphQLOutputType ,
1941
1937
asyncPayloadRecord : StreamRecord ,
1942
- fieldPath : Path ,
1938
+ itemPath : Path ,
1943
1939
) : Promise < IteratorResult < unknown > > {
1944
1940
let item ;
1945
1941
try {
@@ -1950,9 +1946,8 @@ async function executeStreamIteratorItem(
1950
1946
}
1951
1947
item = value ;
1952
1948
} catch ( rawError ) {
1953
- const error = locatedError ( rawError , fieldNodes , pathToArray ( fieldPath ) ) ;
1949
+ const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1954
1950
const value = handleFieldError ( error , itemType , asyncPayloadRecord . errors ) ;
1955
- filterSubsequentPayloads ( exeContext , fieldPath , asyncPayloadRecord ) ;
1956
1951
// don't continue if iterator throws
1957
1952
return { done : true , value } ;
1958
1953
}
@@ -1963,32 +1958,28 @@ async function executeStreamIteratorItem(
1963
1958
itemType ,
1964
1959
fieldNodes ,
1965
1960
info ,
1966
- fieldPath ,
1961
+ itemPath ,
1967
1962
item ,
1968
1963
asyncPayloadRecord ,
1969
1964
) ;
1970
1965
1971
1966
if ( isPromise ( completedItem ) ) {
1972
1967
completedItem = completedItem . then ( undefined , ( rawError ) => {
1973
- const error = locatedError (
1974
- rawError ,
1975
- fieldNodes ,
1976
- pathToArray ( fieldPath ) ,
1977
- ) ;
1968
+ const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1978
1969
const handledError = handleFieldError (
1979
1970
error ,
1980
1971
itemType ,
1981
1972
asyncPayloadRecord . errors ,
1982
1973
) ;
1983
- filterSubsequentPayloads ( exeContext , fieldPath , asyncPayloadRecord ) ;
1974
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1984
1975
return handledError ;
1985
1976
} ) ;
1986
1977
}
1987
1978
return { done : false , value : completedItem } ;
1988
1979
} catch ( rawError ) {
1989
- const error = locatedError ( rawError , fieldNodes , pathToArray ( fieldPath ) ) ;
1980
+ const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1990
1981
const value = handleFieldError ( error , itemType , asyncPayloadRecord . errors ) ;
1991
- filterSubsequentPayloads ( exeContext , fieldPath , asyncPayloadRecord ) ;
1982
+ filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1992
1983
return { done : false , value } ;
1993
1984
}
1994
1985
}
@@ -2008,10 +1999,10 @@ async function executeStreamIterator(
2008
1999
let previousAsyncPayloadRecord = parentContext ?? undefined ;
2009
2000
// eslint-disable-next-line no-constant-condition
2010
2001
while ( true ) {
2011
- const fieldPath = addPath ( path , index , undefined ) ;
2002
+ const itemPath = addPath ( path , index , undefined ) ;
2012
2003
const asyncPayloadRecord = new StreamRecord ( {
2013
2004
label,
2014
- path : fieldPath ,
2005
+ path : itemPath ,
2015
2006
parentContext : previousAsyncPayloadRecord ,
2016
2007
iterator,
2017
2008
exeContext,
@@ -2024,7 +2015,7 @@ async function executeStreamIterator(
2024
2015
info ,
2025
2016
itemType ,
2026
2017
asyncPayloadRecord ,
2027
- fieldPath ,
2018
+ itemPath ,
2028
2019
) ;
2029
2020
2030
2021
asyncPayloadRecord . addItems (
0 commit comments