Skip to content

Commit 46f29f4

Browse files
authored
use operation.selectionSet as argument to collectFields() instead of operation (#4309)
this is the 16.x.x behavior, unlocked by #4308, further reducing the set of breaking changes to this utility
1 parent 32c5b0d commit 46f29f4

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/execution/collectFields.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
FragmentDefinitionNode,
77
FragmentSpreadNode,
88
InlineFragmentNode,
9-
OperationDefinitionNode,
109
SelectionSetNode,
1110
} from '../language/ast.js';
1211
import { Kind } from '../language/kinds.js';
@@ -70,7 +69,7 @@ export function collectFields(
7069
fragments: ObjMap<FragmentDetails>,
7170
variableValues: VariableValues,
7271
runtimeType: GraphQLObjectType,
73-
operation: OperationDefinitionNode,
72+
selectionSet: SelectionSetNode,
7473
hideSuggestions: boolean,
7574
): {
7675
groupedFieldSet: GroupedFieldSet;
@@ -87,12 +86,7 @@ export function collectFields(
8786
hideSuggestions,
8887
};
8988

90-
collectFieldsImpl(
91-
context,
92-
operation.selectionSet,
93-
groupedFieldSet,
94-
newDeferUsages,
95-
);
89+
collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages);
9690
return { groupedFieldSet, newDeferUsages };
9791
}
9892

src/execution/execute.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,12 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
337337
hideSuggestions,
338338
} = validatedExecutionArgs;
339339

340-
const rootType = schema.getRootType(operation.operation);
340+
const { operation: operationType, selectionSet } = operation;
341+
342+
const rootType = schema.getRootType(operationType);
341343
if (rootType == null) {
342344
throw new GraphQLError(
343-
`Schema is not configured to execute ${operation.operation} operation.`,
345+
`Schema is not configured to execute ${operationType} operation.`,
344346
{ nodes: operation },
345347
);
346348
}
@@ -350,7 +352,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
350352
fragments,
351353
variableValues,
352354
rootType,
353-
operation,
355+
selectionSet,
354356
hideSuggestions,
355357
);
356358

@@ -2244,7 +2246,7 @@ function executeSubscription(
22442246
fragments,
22452247
variableValues,
22462248
rootType,
2247-
operation,
2249+
operation.selectionSet,
22482250
hideSuggestions,
22492251
);
22502252

src/validation/rules/SingleFieldSubscriptionsRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function SingleFieldSubscriptionsRule(
5050
fragments,
5151
variableValues,
5252
subscriptionType,
53-
node,
53+
node.selectionSet,
5454
context.hideSuggestions,
5555
);
5656
if (groupedFieldSet.size > 1) {

0 commit comments

Comments
 (0)