Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip unnecessary initialization of empty items array #3962

Merged
merged 1 commit into from
Aug 28, 2023
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
8 changes: 5 additions & 3 deletions src/execution/IncrementalPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ export class IncrementalPublisher {
continue;
}
const incrementalResult: IncrementalStreamResult = {
items: subsequentResultRecord.items,
// safe because `items` is always defined when the record is completed
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
items: subsequentResultRecord.items!,
// safe because `id` is defined once the stream has been released as pending
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
id: subsequentResultRecord.streamRecord.id!,
Expand Down Expand Up @@ -624,6 +626,7 @@ export class IncrementalPublisher {
);
const id = recordWithLongestPath.id;
const incrementalDeferResult: IncrementalDeferResult = {
// safe because `data``is always defined when the record is completed
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
data: data!,
// safe because `id` is defined once the fragment has been released as pending
Expand Down Expand Up @@ -825,7 +828,7 @@ export class StreamItemsRecord {
errors: Array<GraphQLError>;
streamRecord: StreamRecord;
path: ReadonlyArray<string | number>;
items: Array<unknown>;
items: Array<unknown> | undefined;
children: Set<SubsequentResultRecord>;
isFinalRecord?: boolean;
isCompletedAsyncIterator?: boolean;
Expand All @@ -839,7 +842,6 @@ export class StreamItemsRecord {
this.errors = [];
this.isCompleted = false;
this.filtered = false;
this.items = [];
}
}

Expand Down