Skip to content

perf: allow skipping of field plan generation #4050

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

Merged
merged 7 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor collectAndExecuteSubfields (#185)
Co-authored-by: Rob Richard <[email protected]>
  • Loading branch information
yaacovCR and robrichard authored Apr 19, 2024
commit 4e5051a1383840e77b003b1d4c589d5a7ccbdb17
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