Skip to content

Commit dde52d7

Browse files
committed
We don't require keying by spread + arguments
This tends to comment https://github.com/graphql/graphql-js/pull/3835/files#r1100999816
1 parent e33eead commit dde52d7

File tree

3 files changed

+8
-36
lines changed

3 files changed

+8
-36
lines changed

src/execution/collectFields.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '../type/directives.js';
2323
import type { GraphQLSchema } from '../type/schema.js';
2424

25-
import { keyForFragmentSpread } from '../utilities/keyForFragmentSpread.js';
2625
import { substituteFragmentArguments } from '../utilities/substituteFragmentArguments.js';
2726
import { typeFromAST } from '../utilities/typeFromAST.js';
2827

@@ -44,7 +43,7 @@ interface CollectFieldsContext {
4443
variableValues: { [variable: string]: unknown };
4544
operation: OperationDefinitionNode;
4645
runtimeType: GraphQLObjectType;
47-
visitedFragmentKeys: Set<string>;
46+
visitedFragmentNames: Set<string>;
4847
}
4948

5049
/**
@@ -70,7 +69,7 @@ export function collectFields(
7069
variableValues,
7170
runtimeType,
7271
operation,
73-
visitedFragmentKeys: new Set(),
72+
visitedFragmentNames: new Set(),
7473
};
7574

7675
collectFieldsImpl(context, operation.selectionSet, groupedFieldSet);
@@ -102,7 +101,7 @@ export function collectSubfields(
102101
variableValues,
103102
runtimeType: returnType,
104103
operation,
105-
visitedFragmentKeys: new Set(),
104+
visitedFragmentNames: new Set(),
106105
};
107106
const subGroupedFieldSet = new AccumulatorMap<string, FieldDetails>();
108107

@@ -134,7 +133,7 @@ function collectFieldsImpl(
134133
variableValues,
135134
runtimeType,
136135
operation,
137-
visitedFragmentKeys,
136+
visitedFragmentNames,
138137
} = context;
139138

140139
for (const selection of selectionSet.selections) {
@@ -175,7 +174,7 @@ function collectFieldsImpl(
175174
break;
176175
}
177176
case Kind.FRAGMENT_SPREAD: {
178-
const fragmentKey = keyForFragmentSpread(selection);
177+
const fragmentName = selection.name.value;
179178

180179
const newDeferUsage = getDeferUsage(
181180
operation,
@@ -186,13 +185,13 @@ function collectFieldsImpl(
186185

187186
if (
188187
!newDeferUsage &&
189-
(visitedFragmentKeys.has(fragmentKey) ||
188+
(visitedFragmentNames.has(fragmentName) ||
190189
!shouldIncludeNode(variableValues, selection))
191190
) {
192191
continue;
193192
}
194193

195-
const fragment = fragments[selection.name.value];
194+
const fragment = fragments[fragmentName];
196195
if (
197196
fragment == null ||
198197
!doesFragmentConditionMatch(schema, fragment, runtimeType)
@@ -201,7 +200,7 @@ function collectFieldsImpl(
201200
}
202201

203202
if (!newDeferUsage) {
204-
visitedFragmentKeys.add(fragmentKey);
203+
visitedFragmentNames.add(fragmentName);
205204
}
206205

207206
const fragmentSelectionSet = substituteFragmentArguments(

src/utilities/keyForFragmentSpread.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/utilities/substituteFragmentArguments.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import type {
1111
import { Kind } from '../language/kinds.js';
1212
import { visit } from '../language/visitor.js';
1313

14-
// TODO: follow up on https://github.com/graphql/graphql-js/pull/3835/files#r1101010604
15-
1614
/**
1715
* Replaces all fragment argument values with non-fragment-scoped values.
1816
*

0 commit comments

Comments
 (0)