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

rename FieldGroup type to FieldDetailsList #4216

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 12 additions & 9 deletions src/execution/buildExecutionPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isSameSet } from '../jsutils/isSameSet.js';

import type {
DeferUsage,
FieldGroup,
FieldDetailsList,
GroupedFieldSet,
} from './collectFields.js';

Expand All @@ -18,13 +18,16 @@ export function buildExecutionPlan(
originalGroupedFieldSet: GroupedFieldSet,
parentDeferUsages: DeferUsageSet = new Set<DeferUsage>(),
): ExecutionPlan {
const groupedFieldSet = new Map<string, FieldGroup>();
const newGroupedFieldSets = new Map<DeferUsageSet, Map<string, FieldGroup>>();
for (const [responseKey, fieldGroup] of originalGroupedFieldSet) {
const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldGroup);
const groupedFieldSet = new Map<string, FieldDetailsList>();
const newGroupedFieldSets = new Map<
DeferUsageSet,
Map<string, FieldDetailsList>
>();
for (const [responseKey, fieldDetailsList] of originalGroupedFieldSet) {
const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldDetailsList);

if (isSameSet(filteredDeferUsageSet, parentDeferUsages)) {
groupedFieldSet.set(responseKey, fieldGroup);
groupedFieldSet.set(responseKey, fieldDetailsList);
continue;
}

Expand All @@ -36,7 +39,7 @@ export function buildExecutionPlan(
newGroupedFieldSet = new Map();
newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet);
}
newGroupedFieldSet.set(responseKey, fieldGroup);
newGroupedFieldSet.set(responseKey, fieldDetailsList);
}

return {
Expand All @@ -46,10 +49,10 @@ export function buildExecutionPlan(
}

function getFilteredDeferUsageSet(
fieldGroup: FieldGroup,
fieldDetailsList: FieldDetailsList,
): ReadonlySet<DeferUsage> {
const filteredDeferUsageSet = new Set<DeferUsage>();
for (const fieldDetails of fieldGroup) {
for (const fieldDetails of fieldDetailsList) {
const deferUsage = fieldDetails.deferUsage;
if (deferUsage === undefined) {
filteredDeferUsageSet.clear();
Expand Down
8 changes: 4 additions & 4 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export interface FieldDetails {
fragmentVariableValues?: VariableValues | undefined;
}

export type FieldGroup = ReadonlyArray<FieldDetails>;
export type FieldDetailsList = ReadonlyArray<FieldDetails>;

export type GroupedFieldSet = ReadonlyMap<string, FieldGroup>;
export type GroupedFieldSet = ReadonlyMap<string, FieldDetailsList>;

export interface FragmentDetails {
definition: FragmentDefinitionNode;
Expand Down Expand Up @@ -113,7 +113,7 @@ export function collectSubfields(
variableValues: VariableValues,
operation: OperationDefinitionNode,
returnType: GraphQLObjectType,
fieldGroup: FieldGroup,
fieldDetailsList: FieldDetailsList,
): {
groupedFieldSet: GroupedFieldSet;
newDeferUsages: ReadonlyArray<DeferUsage>;
Expand All @@ -129,7 +129,7 @@ export function collectSubfields(
const subGroupedFieldSet = new AccumulatorMap<string, FieldDetails>();
const newDeferUsages: Array<DeferUsage> = [];

for (const fieldDetail of fieldGroup) {
for (const fieldDetail of fieldDetailsList) {
const selectionSet = fieldDetail.node.selectionSet;
if (selectionSet) {
const { deferUsage, fragmentVariableValues } = fieldDetail;
Expand Down
Loading
Loading