Skip to content

Commit

Permalink
rename fieldPath to itemPath
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Sep 20, 2022
1 parent fda7744 commit 58eaf9d
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ async function completeAsyncIteratorValue(
break;
}

const fieldPath = addPath(path, index, undefined);
const itemPath = addPath(path, index, undefined);
let iteration;
try {
// eslint-disable-next-line no-await-in-loop
Expand All @@ -1005,7 +1005,7 @@ async function completeAsyncIteratorValue(
break;
}
} catch (rawError) {
const error = locatedError(rawError, fieldNodes, pathToArray(fieldPath));
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
completedResults.push(handleFieldError(error, itemType, errors));
break;
}
Expand All @@ -1019,7 +1019,7 @@ async function completeAsyncIteratorValue(
itemType,
fieldNodes,
info,
fieldPath,
itemPath,
asyncPayloadRecord,
)
) {
Expand Down Expand Up @@ -1952,7 +1952,7 @@ async function executeStreamIteratorItem(
info: GraphQLResolveInfo,
itemType: GraphQLOutputType,
asyncPayloadRecord: StreamRecord,
fieldPath: Path,
itemPath: Path,
): Promise<IteratorResult<unknown>> {
let item;
try {
Expand All @@ -1963,9 +1963,9 @@ async function executeStreamIteratorItem(
}
item = value;
} catch (rawError) {
const error = locatedError(rawError, fieldNodes, pathToArray(fieldPath));
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
const value = handleFieldError(error, itemType, asyncPayloadRecord.errors);
filterSubsequentPayloads(exeContext, fieldPath, asyncPayloadRecord);
filterSubsequentPayloads(exeContext, itemPath, asyncPayloadRecord);
// don't continue if iterator throws
return { done: true, value };
}
Expand All @@ -1976,32 +1976,28 @@ async function executeStreamIteratorItem(
itemType,
fieldNodes,
info,
fieldPath,
itemPath,
item,
asyncPayloadRecord,
);

if (isPromise(completedItem)) {
completedItem = completedItem.then(undefined, (rawError) => {
const error = locatedError(
rawError,
fieldNodes,
pathToArray(fieldPath),
);
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
const handledError = handleFieldError(
error,
itemType,
asyncPayloadRecord.errors,
);
filterSubsequentPayloads(exeContext, fieldPath, asyncPayloadRecord);
filterSubsequentPayloads(exeContext, itemPath, asyncPayloadRecord);
return handledError;
});
}
return { done: false, value: completedItem };
} catch (rawError) {
const error = locatedError(rawError, fieldNodes, pathToArray(fieldPath));
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
const value = handleFieldError(error, itemType, asyncPayloadRecord.errors);
filterSubsequentPayloads(exeContext, fieldPath, asyncPayloadRecord);
filterSubsequentPayloads(exeContext, itemPath, asyncPayloadRecord);
return { done: false, value };
}
}
Expand All @@ -2021,10 +2017,10 @@ async function executeStreamIterator(
let previousAsyncPayloadRecord = parentContext ?? undefined;
// eslint-disable-next-line no-constant-condition
while (true) {
const fieldPath = addPath(path, index, undefined);
const itemPath = addPath(path, index, undefined);
const asyncPayloadRecord = new StreamRecord({
label,
path: fieldPath,
path: itemPath,
parentContext: previousAsyncPayloadRecord,
iterator,
exeContext,
Expand All @@ -2037,7 +2033,7 @@ async function executeStreamIterator(
info,
itemType,
asyncPayloadRecord,
fieldPath,
itemPath,
);

asyncPayloadRecord.addItems(
Expand Down

0 comments on commit 58eaf9d

Please sign in to comment.