Skip to content

Commit 99efd81

Browse files
committed
rearrange methods
1 parent 3befc39 commit 99efd81

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/execution/execute.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,14 +2640,23 @@ class DeferredFragmentRecord {
26402640
}
26412641
}
26422642

2643-
removePendingTree(path: Path<FieldGroup>) {
2644-
const children = this._results.get(path);
2645-
if (children !== undefined) {
2646-
for (const [childPath] of children) {
2647-
this.removePendingTree(childPath);
2643+
reportDeferredValue(path: Path<FieldGroup>, result: unknown) {
2644+
this._pending.delete(path);
2645+
const siblings = this._results.get(path.prev);
2646+
if (siblings !== undefined) {
2647+
const existingValue = siblings.get(path);
2648+
// if a null has already bubbled, do not overwrite
2649+
if (existingValue === undefined) {
2650+
siblings.set(path, result);
26482651
}
26492652
}
2650-
this.removePendingField(path);
2653+
this.completeIfReady();
2654+
}
2655+
2656+
completeIfReady() {
2657+
if (this._pending.size === 0) {
2658+
this.complete();
2659+
}
26512660
}
26522661

26532662
complete(): void {
@@ -2661,18 +2670,6 @@ class DeferredFragmentRecord {
26612670
this._resolve?.(this.data);
26622671
}
26632672

2664-
addValue(path: Path<FieldGroup>, value: unknown): void {
2665-
this._pending.delete(path);
2666-
const siblings = this._results.get(path.prev);
2667-
if (siblings !== undefined) {
2668-
const existingValue = siblings.get(path);
2669-
// if a null has already bubbled, do not overwrite
2670-
if (existingValue === undefined) {
2671-
siblings.set(path, value);
2672-
}
2673-
}
2674-
}
2675-
26762673
addError(path: Path<FieldGroup>, error: GraphQLError): void {
26772674
this.errors.push(error);
26782675
this.removePendingTree(path);
@@ -2683,15 +2680,14 @@ class DeferredFragmentRecord {
26832680
}
26842681
}
26852682

2686-
completeIfReady() {
2687-
if (this._pending.size === 0) {
2688-
this.complete();
2683+
removePendingTree(path: Path<FieldGroup>) {
2684+
const children = this._results.get(path);
2685+
if (children !== undefined) {
2686+
for (const [childPath] of children) {
2687+
this.removePendingTree(childPath);
2688+
}
26892689
}
2690-
}
2691-
2692-
reportDeferredValue(path: Path<FieldGroup>, result: unknown) {
2693-
this.addValue(path, result);
2694-
this.completeIfReady();
2690+
this.removePendingField(path);
26952691
}
26962692

26972693
_buildData(

0 commit comments

Comments
 (0)