Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor collectAndExecuteSubfields #185

Merged
merged 1 commit into from
Apr 19, 2024
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
68 changes: 16 additions & 52 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1588,64 +1588,28 @@ function collectAndExecuteSubfields(
// Collect sub-fields to execute to complete this value.
const { groupedFieldSet: nonPartitionedGroupedFieldSet, newDeferUsages } =
collectSubfields(exeContext, returnType, fieldGroup);
let groupedFieldSet = nonPartitionedGroupedFieldSet;
let newGroupedFieldSets;
let newDeferMap = deferMap;
let hasDefers = Boolean(deferMap) || Boolean(newDeferUsages.length);

if (newDeferUsages.length === 0) {
if (deferMap === undefined) {
return executeFields(
exeContext,
returnType,
result,
path,
nonPartitionedGroupedFieldSet,
incrementalContext,
undefined,
);
}

const { groupedFieldSet, newGroupedFieldSets } = buildSubFieldPlan(
if (hasDefers) {
({ groupedFieldSet, newGroupedFieldSets } = buildSubFieldPlan(
nonPartitionedGroupedFieldSet,
incrementalContext?.deferUsageSet,
);

const subFields = executeFields(
exeContext,
returnType,
result,
path,
groupedFieldSet,
incrementalContext,
deferMap,
);

));
if (newGroupedFieldSets.size > 0) {
const newDeferredGroupedFieldSetRecords = executeDeferredGroupedFieldSets(
exeContext,
returnType,
result,
path,
incrementalContext?.deferUsageSet,
newGroupedFieldSets,
deferMap,
);

return withNewDeferredGroupedFieldSets(
subFields,
newDeferredGroupedFieldSetRecords,
);
hasDefers = true;
}
return subFields;
}

const { groupedFieldSet, newGroupedFieldSets } = buildSubFieldPlan(
nonPartitionedGroupedFieldSet,
incrementalContext?.deferUsageSet,
);

const newDeferMap = addNewDeferredFragments(
newDeferUsages,
new Map(deferMap),
path,
);
if (hasDefers) {
newDeferMap = addNewDeferredFragments(
newDeferUsages,
new Map(deferMap),
path,
);
}

const subFields = executeFields(
exeContext,
Expand All @@ -1657,7 +1621,7 @@ function collectAndExecuteSubfields(
newDeferMap,
);

if (newGroupedFieldSets.size > 0) {
if (newGroupedFieldSets && newDeferMap) {
const newDeferredGroupedFieldSetRecords = executeDeferredGroupedFieldSets(
exeContext,
returnType,
Expand Down
Loading