Skip to content
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
35 changes: 11 additions & 24 deletions src/execution/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ export class Executor<
this.promiseAll = promiseAll;
}

executeRootSelectionSet(): PromiseOrValue<
ExecutionResult | TAlternativeInitialResponse
> {
executeRootSelectionSet(
serially?: boolean,
): PromiseOrValue<ExecutionResult | TAlternativeInitialResponse> {
const externalAbortSignal = this.validatedExecutionArgs.externalAbortSignal;
let removeExternalAbortListener: (() => void) | undefined;
if (externalAbortSignal) {
Expand Down Expand Up @@ -322,10 +322,10 @@ export class Executor<
);

result = this.executeCollectedRootFields(
operation.operation,
rootType,
rootValue,
groupedFieldSet,
serially ?? operationType === OperationTypeNode.MUTATION,
newDeferUsages,
);

Expand Down Expand Up @@ -420,56 +420,43 @@ export class Executor<
}

executeCollectedRootFields(
operation: OperationTypeNode,
rootType: GraphQLObjectType,
rootValue: unknown,
originalGroupedFieldSet: GroupedFieldSet,
serially: boolean,
_newDeferUsages: ReadonlyArray<DeferUsage>,
): PromiseOrValue<ObjMap<unknown>> {
return this.executeRootGroupedFieldSet(
operation,
rootType,
rootValue,
originalGroupedFieldSet,
serially,
undefined,
);
}

executeRootGroupedFieldSet(
operation: OperationTypeNode,
rootType: GraphQLObjectType,
rootValue: unknown,
groupedFieldSet: GroupedFieldSet,
serially: boolean,
positionContext?: TPositionContext,
): PromiseOrValue<ObjMap<unknown>> {
switch (operation) {
case OperationTypeNode.QUERY:
return this.executeFields(
return serially
? this.executeFieldsSerially(
rootType,
rootValue,
undefined,
groupedFieldSet,
positionContext,
);
case OperationTypeNode.MUTATION:
return this.executeFieldsSerially(
rootType,
rootValue,
undefined,
groupedFieldSet,
positionContext,
);
case OperationTypeNode.SUBSCRIPTION:
// TODO: deprecate `subscribe` and move all logic here
// Temporary solution until we finish merging execute and subscribe together
return this.executeFields(
)
: this.executeFields(
rootType,
rootValue,
undefined,
groupedFieldSet,
positionContext,
);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/execution/ExecutorThrowingOnIncremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const UNEXPECTED_MULTIPLE_PAYLOADS =
/** @internal */
export class ExecutorThrowingOnIncremental extends Executor {
override executeCollectedRootFields(
operation: OperationTypeNode,
rootType: GraphQLObjectType,
rootValue: unknown,
originalGroupedFieldSet: GroupedFieldSet,
serially: boolean,
newDeferUsages: ReadonlyArray<DeferUsage>,
): PromiseOrValue<ObjMap<unknown>> {
if (newDeferUsages.length > 0) {
Expand All @@ -42,10 +42,10 @@ export class ExecutorThrowingOnIncremental extends Executor {
throw reason;
}
return this.executeRootGroupedFieldSet(
operation,
rootType,
rootValue,
originalGroupedFieldSet,
serially,
undefined,
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ export function executeSync(args: ExecutionArgs): ExecutionResult {
export function executeSubscriptionEvent(
validatedExecutionArgs: ValidatedSubscriptionArgs,
): PromiseOrValue<ExecutionResult> {
return executeRootSelectionSet(validatedExecutionArgs);
return new ExecutorThrowingOnIncremental(
validatedExecutionArgs,
).executeRootSelectionSet(false);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/execution/incremental/IncrementalExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,18 @@ export class IncrementalExecutor<
}

override executeCollectedRootFields(
operation: OperationTypeNode,
rootType: GraphQLObjectType,
rootValue: unknown,
originalGroupedFieldSet: GroupedFieldSet,
serially: boolean,
newDeferUsages: ReadonlyArray<DeferUsage>,
): PromiseOrValue<ObjMap<unknown>> {
if (newDeferUsages.length === 0) {
return this.executeRootGroupedFieldSet(
operation,
rootType,
rootValue,
originalGroupedFieldSet,
serially,
undefined,
);
}
Expand All @@ -391,10 +391,10 @@ export class IncrementalExecutor<
this.buildRootExecutionPlan(originalGroupedFieldSet);

const data = this.executeRootGroupedFieldSet(
operation,
rootType,
rootValue,
groupedFieldSet,
serially,
newDeliveryGroupMap,
);

Expand Down
Loading