Skip to content

Commit

Permalink
refactor: move executeStreamField out of try
Browse files Browse the repository at this point in the history
this function should catches errors and should never throw
  • Loading branch information
yaacovCR committed Sep 28, 2022
1 parent bd5aae7 commit 419fd37
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1103,28 +1103,29 @@ function completeListValue(
// No need to modify the info object containing the path,
// since from here on it is not ever accessed by resolver functions.
const itemPath = addPath(path, index, undefined);

if (
stream &&
typeof stream.initialCount === 'number' &&
index >= stream.initialCount
) {
previousAsyncPayloadRecord = executeStreamField(
path,
itemPath,
item,
exeContext,
fieldNodes,
info,
itemType,
stream.label,
previousAsyncPayloadRecord,
);
index++;
continue;
}

try {
let completedItem;

if (
stream &&
typeof stream.initialCount === 'number' &&
index >= stream.initialCount
) {
previousAsyncPayloadRecord = executeStreamField(
path,
itemPath,
item,
exeContext,
fieldNodes,
info,
itemType,
stream.label,
previousAsyncPayloadRecord,
);
index++;
continue;
}
if (isPromise(item)) {
completedItem = item.then((resolved) =>
completeValue(
Expand Down

0 comments on commit 419fd37

Please sign in to comment.