@@ -2640,14 +2640,23 @@ class DeferredFragmentRecord {
2640
2640
}
2641
2641
}
2642
2642
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 ) ;
2648
2651
}
2649
2652
}
2650
- this . removePendingField ( path ) ;
2653
+ this . completeIfReady ( ) ;
2654
+ }
2655
+
2656
+ completeIfReady ( ) {
2657
+ if ( this . _pending . size === 0 ) {
2658
+ this . complete ( ) ;
2659
+ }
2651
2660
}
2652
2661
2653
2662
complete ( ) : void {
@@ -2661,18 +2670,6 @@ class DeferredFragmentRecord {
2661
2670
this . _resolve ?.( this . data ) ;
2662
2671
}
2663
2672
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
-
2676
2673
addError ( path : Path < FieldGroup > , error : GraphQLError ) : void {
2677
2674
this . errors . push ( error ) ;
2678
2675
this . removePendingTree ( path ) ;
@@ -2683,15 +2680,14 @@ class DeferredFragmentRecord {
2683
2680
}
2684
2681
}
2685
2682
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
+ }
2689
2689
}
2690
- }
2691
-
2692
- reportDeferredValue ( path : Path < FieldGroup > , result : unknown ) {
2693
- this . addValue ( path , result ) ;
2694
- this . completeIfReady ( ) ;
2690
+ this . removePendingField ( path ) ;
2695
2691
}
2696
2692
2697
2693
_buildData (
0 commit comments