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 28, 2022
1 parent 2991c79 commit 71a8db4
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 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);
try {
// eslint-disable-next-line no-await-in-loop
const { value, done } = await iterator.next();
Expand All @@ -1011,7 +1011,7 @@ async function completeAsyncIteratorValue(
itemType,
fieldNodes,
info,
fieldPath,
itemPath,
value,
asyncPayloadRecord,
);
Expand All @@ -1024,10 +1024,10 @@ async function completeAsyncIteratorValue(
const error = locatedError(
rawError,
fieldNodes,
pathToArray(fieldPath),
pathToArray(itemPath),
);
const handledError = handleFieldError(error, itemType, errors);
filterSubsequentPayloads(exeContext, fieldPath);
filterSubsequentPayloads(exeContext, itemPath);
return handledError;
}),
);
Expand All @@ -1036,16 +1036,12 @@ async function completeAsyncIteratorValue(
}
} catch (rawError) {
completedResults.push(null);
const error = locatedError(
rawError,
fieldNodes,
pathToArray(fieldPath),
);
filterSubsequentPayloads(exeContext, fieldPath);
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
filterSubsequentPayloads(exeContext, itemPath);
handleFieldError(error, itemType, errors);
}
} catch (rawError) {
const error = locatedError(rawError, fieldNodes, pathToArray(fieldPath));
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
completedResults.push(handleFieldError(error, itemType, errors));
break;
}
Expand Down Expand Up @@ -1939,7 +1935,7 @@ async function executeStreamIteratorItem(
info: GraphQLResolveInfo,
itemType: GraphQLOutputType,
asyncPayloadRecord: StreamRecord,
fieldPath: Path,
itemPath: Path,
): Promise<IteratorResult<unknown>> {
let item;
try {
Expand All @@ -1950,9 +1946,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 @@ -1963,32 +1959,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 @@ -2008,10 +2000,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 @@ -2024,7 +2016,7 @@ async function executeStreamIterator(
info,
itemType,
asyncPayloadRecord,
fieldPath,
itemPath,
);

asyncPayloadRecord.addItems(
Expand Down

0 comments on commit 71a8db4

Please sign in to comment.