Skip to content

Commit

Permalink
use operaton.selectionSet as argument to collectFields instead of ope…
Browse files Browse the repository at this point in the history
…ration

this is the 16.x.x behavior, unlocked by graphql#4308
  • Loading branch information
yaacovCR committed Dec 10, 2024
1 parent 32c5b0d commit 554053c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
10 changes: 2 additions & 8 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
FragmentDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
OperationDefinitionNode,
SelectionSetNode,
} from '../language/ast.js';
import { Kind } from '../language/kinds.js';
Expand Down Expand Up @@ -70,7 +69,7 @@ export function collectFields(
fragments: ObjMap<FragmentDetails>,
variableValues: VariableValues,
runtimeType: GraphQLObjectType,
operation: OperationDefinitionNode,
selectionSet: SelectionSetNode,
hideSuggestions: boolean,
): {
groupedFieldSet: GroupedFieldSet;
Expand All @@ -87,12 +86,7 @@ export function collectFields(
hideSuggestions,
};

collectFieldsImpl(
context,
operation.selectionSet,
groupedFieldSet,
newDeferUsages,
);
collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages);
return { groupedFieldSet, newDeferUsages };
}

Expand Down
10 changes: 6 additions & 4 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
hideSuggestions,
} = validatedExecutionArgs;

const rootType = schema.getRootType(operation.operation);
const { operation: operationType, selectionSet } = operation;

const rootType = schema.getRootType(operationType);
if (rootType == null) {
throw new GraphQLError(
`Schema is not configured to execute ${operation.operation} operation.`,
`Schema is not configured to execute ${operationType} operation.`,
{ nodes: operation },
);
}
Expand All @@ -350,7 +352,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
fragments,
variableValues,
rootType,
operation,
selectionSet,
hideSuggestions,
);

Expand Down Expand Up @@ -2244,7 +2246,7 @@ function executeSubscription(
fragments,
variableValues,
rootType,
operation,
operation.selectionSet,
hideSuggestions,
);

Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/SingleFieldSubscriptionsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function SingleFieldSubscriptionsRule(
fragments,
variableValues,
subscriptionType,
node,
node.selectionSet,
context.hideSuggestions,
);
if (groupedFieldSet.size > 1) {
Expand Down

0 comments on commit 554053c

Please sign in to comment.