Skip to content

Commit f3e7703

Browse files
committed
remove completePromisedListItemValue
1 parent 02f823a commit f3e7703

File tree

1 file changed

+21
-107
lines changed

1 file changed

+21
-107
lines changed

src/execution/execute.ts

+21-107
Original file line numberDiff line numberDiff line change
@@ -1114,27 +1114,9 @@ async function completeAsyncIteratorValue(
11141114
break;
11151115
}
11161116

1117-
const item = iteration.value;
1118-
// TODO: add test case for asyncIterator returning a promise
1119-
/* c8 ignore start */
1120-
if (isPromise(item)) {
1121-
completedResults.push(
1122-
completePromisedListItemValue(
1123-
item,
1124-
exeContext,
1125-
itemType,
1126-
fieldGroup,
1127-
info,
1128-
itemPath,
1129-
incrementalContext,
1130-
deferMap,
1131-
),
1132-
);
1133-
containsPromise = true;
1134-
} else if (
1135-
/* c8 ignore stop */
1117+
if (
11361118
completeListItemValue(
1137-
item,
1119+
iteration.value,
11381120
completedResults,
11391121
exeContext,
11401122
itemType,
@@ -1227,24 +1209,7 @@ async function completeAsyncIteratorValueWithPossibleStream(
12271209
}
12281210

12291211
const item = iteration.value;
1230-
// TODO: add tests for stream backed by asyncIterator that returns a promise
1231-
/* c8 ignore start */
1232-
if (isPromise(item)) {
1233-
completedResults.push(
1234-
completePromisedListItemValue(
1235-
item,
1236-
exeContext,
1237-
itemType,
1238-
fieldGroup,
1239-
info,
1240-
itemPath,
1241-
incrementalContext,
1242-
deferMap,
1243-
),
1244-
);
1245-
containsPromise = true;
1246-
} else if (
1247-
/* c8 ignore stop */
1212+
if (
12481213
completeListItemValue(
12491214
item,
12501215
completedResults,
@@ -1368,21 +1333,7 @@ function completeIterableValue(
13681333
// since from here on it is not ever accessed by resolver functions.
13691334
const itemPath = addPath(path, index, undefined);
13701335

1371-
if (isPromise(item)) {
1372-
completedResults.push(
1373-
completePromisedListItemValue(
1374-
item,
1375-
exeContext,
1376-
itemType,
1377-
fieldGroup,
1378-
info,
1379-
itemPath,
1380-
incrementalContext,
1381-
deferMap,
1382-
),
1383-
);
1384-
containsPromise = true;
1385-
} else if (
1336+
if (
13861337
completeListItemValue(
13871338
item,
13881339
completedResults,
@@ -1459,21 +1410,7 @@ function completeIterableValueWithPossibleStream(
14591410
// since from here on it is not ever accessed by resolver functions.
14601411
const itemPath = addPath(path, index, undefined);
14611412

1462-
if (isPromise(item)) {
1463-
completedResults.push(
1464-
completePromisedListItemValue(
1465-
item,
1466-
exeContext,
1467-
itemType,
1468-
fieldGroup,
1469-
info,
1470-
itemPath,
1471-
incrementalContext,
1472-
deferMap,
1473-
),
1474-
);
1475-
containsPromise = true;
1476-
} else if (
1413+
if (
14771414
completeListItemValue(
14781415
item,
14791416
completedResults,
@@ -1513,6 +1450,22 @@ function completeListItemValue(
15131450
incrementalContext: IncrementalContext | undefined,
15141451
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
15151452
): boolean {
1453+
if (isPromise(item)) {
1454+
completedResults.push(
1455+
completePromisedValue(
1456+
exeContext,
1457+
itemType,
1458+
fieldGroup,
1459+
info,
1460+
itemPath,
1461+
item,
1462+
incrementalContext,
1463+
deferMap,
1464+
),
1465+
);
1466+
return true;
1467+
}
1468+
15161469
try {
15171470
const completedItem = completeValue(
15181471
exeContext,
@@ -1559,45 +1512,6 @@ function completeListItemValue(
15591512
return false;
15601513
}
15611514

1562-
async function completePromisedListItemValue(
1563-
item: unknown,
1564-
exeContext: ExecutionContext,
1565-
itemType: GraphQLOutputType,
1566-
fieldGroup: FieldGroup,
1567-
info: GraphQLResolveInfo,
1568-
itemPath: Path,
1569-
incrementalContext: IncrementalContext | undefined,
1570-
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
1571-
): Promise<unknown> {
1572-
try {
1573-
const resolved = await item;
1574-
let completed = completeValue(
1575-
exeContext,
1576-
itemType,
1577-
fieldGroup,
1578-
info,
1579-
itemPath,
1580-
resolved,
1581-
incrementalContext,
1582-
deferMap,
1583-
);
1584-
if (isPromise(completed)) {
1585-
completed = await completed;
1586-
}
1587-
return completed;
1588-
} catch (rawError) {
1589-
handleFieldError(
1590-
rawError,
1591-
exeContext,
1592-
itemType,
1593-
fieldGroup,
1594-
itemPath,
1595-
incrementalContext,
1596-
);
1597-
return null;
1598-
}
1599-
}
1600-
16011515
/**
16021516
* Complete a Scalar or Enum by serializing to a valid value, returning
16031517
* null if serialization is not possible.

0 commit comments

Comments
 (0)