Skip to content
Merged
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
20 changes: 8 additions & 12 deletions src/execution/IncrementalPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,16 @@ class IncrementalPublisher {
};
}

private _ensureId(deliveryGroup: DeliveryGroup): string {
return (deliveryGroup.id ??= String(this._nextId++));
}

private _toPendingResults(
newRootNodes: ReadonlyArray<DeliveryGroup>,
): Array<PendingResult> {
const pendingResults: Array<PendingResult> = [];
for (const node of newRootNodes) {
const id = String(this._getNextId());
node.id = id;
const id = this._ensureId(node);
const pendingResult: PendingResult = {
id,
path: pathToArray(node.path),
Expand All @@ -125,10 +128,6 @@ class IncrementalPublisher {
return pendingResults;
}

private _getNextId(): string {
return String(this._nextId++);
}

private _handleCompletedBatch(
batch: Iterable<IncrementalDataRecordResult>,
): SubsequentIncrementalExecutionResult | undefined {
Expand Down Expand Up @@ -185,8 +184,7 @@ class IncrementalPublisher {
if (
this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)
) {
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
const id = this._ensureId(deferredFragmentRecord);
context.completed.push({
id,
errors: completedExecutionGroup.errors,
Expand All @@ -208,8 +206,7 @@ class IncrementalPublisher {
if (completion === undefined) {
continue;
}
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
const id = this._ensureId(deferredFragmentRecord);
const incremental = context.incremental;
const { newRootNodes, successfulExecutionGroups } = completion;
context.pending.push(...this._toPendingResults(newRootNodes));
Expand Down Expand Up @@ -237,8 +234,7 @@ class IncrementalPublisher {
context: SubsequentIncrementalExecutionResultContext,
): void {
const streamRecord = streamItemsResult.streamRecord;
const id = streamRecord.id;
invariant(id !== undefined);
const id = this._ensureId(streamRecord);
if (streamItemsResult.errors !== undefined) {
context.completed.push({
id,
Expand Down
Loading