Skip to content

Commit

Permalink
polish(IncrementalPublisher): remove unnecessary check and method call (
Browse files Browse the repository at this point in the history
#4106)

polished IncrementalPublisher:

= completeDeferredFragment will always return undefined if the
deferredFragmentRecord has already been removed from the graph
= removeDeferredFragment need not be called twice
  • Loading branch information
yaacovCR committed Jun 19, 2024
1 parent 75dca3d commit e160b6f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/execution/IncrementalPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class IncrementalPublisher {
id,
errors: deferredGroupedFieldSetResult.errors,
});
this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord);
}
return;
}
Expand All @@ -261,19 +260,13 @@ class IncrementalPublisher {

for (const deferredFragmentRecord of deferredGroupedFieldSetResult
.deferredGroupedFieldSetRecord.deferredFragmentRecords) {
const id = deferredFragmentRecord.id;
// TODO: add test case for this.
// Presumably, this can occur if an error causes a fragment to be completed early,
// while an asynchronous deferred grouped field set result is enqueued.
/* c8 ignore next 3 */
if (id === undefined) {
continue;
}
const reconcilableResults =
this._incrementalGraph.completeDeferredFragment(deferredFragmentRecord);
if (reconcilableResults === undefined) {
continue;
}
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
const incremental = context.incremental;
for (const reconcilableResult of reconcilableResults) {
const { bestId, subPath } = this._getBestIdAndSubPath(
Expand Down

0 comments on commit e160b6f

Please sign in to comment.