Skip to content

Commit 37c9148

Browse files
committed
remove completePromisedListItemValue
1 parent ab72824 commit 37c9148

File tree

1 file changed

+21
-107
lines changed

1 file changed

+21
-107
lines changed

Diff for: src/execution/execute.ts

+21-107
Original file line numberDiff line numberDiff line change
@@ -1134,27 +1134,9 @@ async function completeAsyncIteratorValue(
11341134
break;
11351135
}
11361136

1137-
const item = iteration.value;
1138-
// TODO: add tests for stream backed by asyncIterator that returns a promise
1139-
/* c8 ignore start */
1140-
if (isPromise(item)) {
1141-
completedResults.push(
1142-
completePromisedListItemValue(
1143-
item,
1144-
exeContext,
1145-
itemType,
1146-
fieldGroup,
1147-
info,
1148-
itemPath,
1149-
incrementalContext,
1150-
deferMap,
1151-
),
1152-
);
1153-
containsPromise = true;
1154-
} else if (
1155-
/* c8 ignore stop */
1137+
if (
11561138
completeListItemValue(
1157-
item,
1139+
iteration.value,
11581140
completedResults,
11591141
exeContext,
11601142
itemType,
@@ -1248,24 +1230,7 @@ async function completeAsyncIteratorValueWithPossibleStream(
12481230
}
12491231

12501232
const item = iteration.value;
1251-
// TODO: add tests for stream backed by asyncIterator that returns a promise
1252-
/* c8 ignore start */
1253-
if (isPromise(item)) {
1254-
completedResults.push(
1255-
completePromisedListItemValue(
1256-
item,
1257-
exeContext,
1258-
itemType,
1259-
fieldGroup,
1260-
info,
1261-
itemPath,
1262-
incrementalContext,
1263-
deferMap,
1264-
),
1265-
);
1266-
containsPromise = true;
1267-
} else if (
1268-
/* c8 ignore stop */
1233+
if (
12691234
completeListItemValue(
12701235
item,
12711236
completedResults,
@@ -1389,21 +1354,7 @@ function completeIterableValue(
13891354
// since from here on it is not ever accessed by resolver functions.
13901355
const itemPath = addPath(path, index, undefined);
13911356

1392-
if (isPromise(item)) {
1393-
completedResults.push(
1394-
completePromisedListItemValue(
1395-
item,
1396-
exeContext,
1397-
itemType,
1398-
fieldGroup,
1399-
info,
1400-
itemPath,
1401-
incrementalContext,
1402-
deferMap,
1403-
),
1404-
);
1405-
containsPromise = true;
1406-
} else if (
1357+
if (
14071358
completeListItemValue(
14081359
item,
14091360
completedResults,
@@ -1472,21 +1423,7 @@ function completeIterableValueWithPossibleStream(
14721423
// since from here on it is not ever accessed by resolver functions.
14731424
const itemPath = addPath(path, index, undefined);
14741425

1475-
if (isPromise(item)) {
1476-
completedResults.push(
1477-
completePromisedListItemValue(
1478-
item,
1479-
exeContext,
1480-
itemType,
1481-
fieldGroup,
1482-
info,
1483-
itemPath,
1484-
incrementalContext,
1485-
deferMap,
1486-
),
1487-
);
1488-
containsPromise = true;
1489-
} else if (
1426+
if (
14901427
completeListItemValue(
14911428
item,
14921429
completedResults,
@@ -1525,6 +1462,22 @@ function completeListItemValue(
15251462
incrementalContext: IncrementalContext | undefined,
15261463
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
15271464
): boolean {
1465+
if (isPromise(item)) {
1466+
completedResults.push(
1467+
completePromisedValue(
1468+
exeContext,
1469+
itemType,
1470+
fieldGroup,
1471+
info,
1472+
itemPath,
1473+
item,
1474+
incrementalContext,
1475+
deferMap,
1476+
),
1477+
);
1478+
return true;
1479+
}
1480+
15281481
try {
15291482
const completedItem = completeValue(
15301483
exeContext,
@@ -1571,45 +1524,6 @@ function completeListItemValue(
15711524
return false;
15721525
}
15731526

1574-
async function completePromisedListItemValue(
1575-
item: unknown,
1576-
exeContext: ExecutionContext,
1577-
itemType: GraphQLOutputType,
1578-
fieldGroup: FieldGroup,
1579-
info: GraphQLResolveInfo,
1580-
itemPath: Path,
1581-
incrementalContext: IncrementalContext | undefined,
1582-
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
1583-
): Promise<unknown> {
1584-
try {
1585-
const resolved = await item;
1586-
let completed = completeValue(
1587-
exeContext,
1588-
itemType,
1589-
fieldGroup,
1590-
info,
1591-
itemPath,
1592-
resolved,
1593-
incrementalContext,
1594-
deferMap,
1595-
);
1596-
if (isPromise(completed)) {
1597-
completed = await completed;
1598-
}
1599-
return completed;
1600-
} catch (rawError) {
1601-
handleFieldError(
1602-
rawError,
1603-
exeContext,
1604-
itemType,
1605-
fieldGroup,
1606-
itemPath,
1607-
incrementalContext,
1608-
);
1609-
return null;
1610-
}
1611-
}
1612-
16131527
/**
16141528
* Complete a Scalar or Enum by serializing to a valid value, returning
16151529
* null if serialization is not possible.

0 commit comments

Comments
 (0)