Skip to content

Commit 143c231

Browse files
committed
introduce GroupedFieldSet and FieldGroup types
1 parent b5eb498 commit 143c231

File tree

3 files changed

+115
-99
lines changed

3 files changed

+115
-99
lines changed

src/execution/collectFields.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ import { typeFromAST } from '../utilities/typeFromAST.js';
2626

2727
import { getDirectiveValues } from './values.js';
2828

29+
export type FieldGroup = ReadonlyArray<FieldNode>;
30+
31+
export type GroupedFieldSet = Map<string, FieldGroup>;
32+
2933
export interface PatchFields {
3034
label: string | undefined;
31-
fields: Map<string, ReadonlyArray<FieldNode>>;
35+
fields: GroupedFieldSet;
3236
}
3337

3438
export interface FieldsAndPatches {
35-
fields: Map<string, ReadonlyArray<FieldNode>>;
39+
fields: GroupedFieldSet;
3640
patches: Array<PatchFields>;
3741
}
3842

@@ -85,7 +89,7 @@ export function collectSubfields(
8589
variableValues: { [variable: string]: unknown },
8690
operation: OperationDefinitionNode,
8791
returnType: GraphQLObjectType,
88-
fieldNodes: ReadonlyArray<FieldNode>,
92+
fieldGroup: FieldGroup,
8993
): FieldsAndPatches {
9094
const subFieldNodes = new AccumulatorMap<string, FieldNode>();
9195
const visitedFragmentNames = new Set<string>();
@@ -96,7 +100,7 @@ export function collectSubfields(
96100
patches: subPatches,
97101
};
98102

99-
for (const node of fieldNodes) {
103+
for (const node of fieldGroup) {
100104
if (node.selectionSet) {
101105
collectFieldsImpl(
102106
schema,

0 commit comments

Comments
 (0)