Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1107,19 +1107,17 @@ async function completeAsyncIteratorValue(
/* c8 ignore start */
if (isPromise(item)) {
completedResults.push(
completePromisedValue(
completePromisedListItemValue(
item,
graphqlWrappedResult,
exeContext,
itemType,
fieldGroup,
info,
itemPath,
item,
incrementalContext,
deferMap,
).then((resolved) => {
graphqlWrappedResult[1].push(...resolved[1]);
return resolved[0];
}),
),
);
containsPromise = true;
} else if (
Expand Down Expand Up @@ -1232,19 +1230,17 @@ function completeListValue(

if (isPromise(item)) {
completedResults.push(
completePromisedValue(
completePromisedListItemValue(
item,
graphqlWrappedResult,
exeContext,
itemType,
fieldGroup,
info,
itemPath,
item,
incrementalContext,
deferMap,
).then((resolved) => {
graphqlWrappedResult[1].push(...resolved[1]);
return resolved[0];
}),
),
);
containsPromise = true;
} else if (
Expand Down Expand Up @@ -1334,6 +1330,41 @@ function completeListItemValue(
return false;
}

async function completePromisedListItemValue(
item: unknown,
parent: GraphQLWrappedResult<Array<unknown>>,
exeContext: ExecutionContext,
itemType: GraphQLOutputType,
fieldGroup: FieldGroup,
info: GraphQLResolveInfo,
itemPath: Path,
incrementalContext: IncrementalContext | undefined,
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
): Promise<unknown> {
try {
const resolved = await item;
let completed = completeValue(
exeContext,
itemType,
fieldGroup,
info,
itemPath,
resolved,
incrementalContext,
deferMap,
);
if (isPromise(completed)) {
completed = await completed;
}
parent[1].push(...completed[1]);
return completed[0];
} catch (rawError) {
const errors = (incrementalContext ?? exeContext).errors;
handleFieldError(rawError, itemType, fieldGroup, itemPath, errors);
return null;
}
}

/**
* Complete a Scalar or Enum by serializing to a valid value, returning
* null if serialization is not possible.
Expand Down