Skip to content

Commit

Permalink
add todos
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Oct 30, 2024
1 parent 3cf7d57 commit 9f634a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/execution/Canceller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export class Canceller {
}

withCancellation<T>(originalPromise: Promise<T>): Promise<T> {
if (this.abortSignal === undefined) {
return originalPromise;
}

const { promise, resolve, reject } = promiseWithResolvers<T>();
const abort = () => reject(this.abortSignal.reason);
this._aborts.add(abort);
Expand Down
3 changes: 3 additions & 0 deletions src/execution/IncrementalPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class IncrementalPublisher {
IteratorResult<SubsequentIncrementalExecutionResult, void>
> => {
if (isDone) {
this._context.canceller?.unsubscribe();
await this._returnAsyncIteratorsIgnoringErrors();
return { value: undefined, done: true };
}
Expand Down Expand Up @@ -173,6 +174,8 @@ class IncrementalPublisher {
batch = await this._incrementalGraph.nextCompletedBatch();
} while (batch !== undefined);

// TODO: add test for this case
/* c8 ignore next */
this._context.canceller?.unsubscribe();
await this._returnAsyncIteratorsIgnoringErrors();
return { value: undefined, done: true };
Expand Down
4 changes: 4 additions & 0 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
}
return buildDataResponse(exeContext, graphqlWrappedResult);
} catch (error) {
// TODO: add test case for synchronous null bubbling to root with cancellation
/* c8 ignore next */
exeContext.canceller?.unsubscribe();
return { data: null, errors: withError(exeContext.errors, error) };
}
Expand Down Expand Up @@ -2205,6 +2207,8 @@ function executeSubscription(
const promise = canceller?.withCancellation(result) ?? result;
return promise.then(assertEventStream).then(
(resolved) => {
// TODO: add test case
/* c8 ignore next */
canceller?.unsubscribe();
return resolved;
},
Expand Down

0 comments on commit 9f634a8

Please sign in to comment.