@@ -522,65 +522,76 @@ describe.each([
522
522
expect ( resolverInternals . _relayResolverTestCallCount ) . toBe ( 1 ) ;
523
523
} ) ;
524
524
525
- it ( 'marks the resolver cache as clean if the upstream has not changed' , ( ) => {
526
- const source = RelayRecordSource . create ( {
527
- 'client:root' : {
528
- __id : 'client:root' ,
529
- __typename : '__Root' ,
530
- me : { __ref : '1' } ,
531
- } ,
532
- '1' : {
533
- __id : '1' ,
534
- id : '1' ,
535
- __typename : 'User' ,
536
- name : 'Alice' ,
537
- } ,
538
- } ) ;
525
+ it . each ( [ true , false ] ) (
526
+ 'marks the resolver cache as clean if the upstream has not changed with RelayFeatureFlags.MARK_RESOLVER_VALUES_AS_CLEAN_AFTER_FRAGMENT_REREAD=%s' ,
527
+ markClean => {
528
+ RelayFeatureFlags . MARK_RESOLVER_VALUES_AS_CLEAN_AFTER_FRAGMENT_REREAD =
529
+ markClean ;
530
+ const source = RelayRecordSource . create ( {
531
+ 'client:root' : {
532
+ __id : 'client:root' ,
533
+ __typename : '__Root' ,
534
+ me : { __ref : '1' } ,
535
+ } ,
536
+ '1' : {
537
+ __id : '1' ,
538
+ id : '1' ,
539
+ __typename : 'User' ,
540
+ name : 'Alice' ,
541
+ } ,
542
+ } ) ;
539
543
540
- const store = new RelayStore ( source , { gcReleaseBufferSize : 0 } ) ;
541
- const environment = new RelayModernEnvironment ( {
542
- network : RelayNetwork . create ( jest . fn ( ) ) ,
543
- store,
544
- } ) ;
544
+ const store = new RelayStore ( source , { gcReleaseBufferSize : 0 } ) ;
545
+ const environment = new RelayModernEnvironment ( {
546
+ network : RelayNetwork . create ( jest . fn ( ) ) ,
547
+ store,
548
+ } ) ;
545
549
546
- const FooQuery = graphql `
547
- query RelayReaderResolverTestMarkCleanQuery {
548
- me {
549
- constant_dependent
550
+ const FooQuery = graphql `
551
+ query RelayReaderResolverTestMarkCleanQuery {
552
+ me {
553
+ constant_dependent
554
+ }
550
555
}
551
- }
552
- ` ;
556
+ ` ;
553
557
554
- const cb = jest . fn < [ Snapshot ] , void > ( ) ;
555
- const operation = createOperationDescriptor ( FooQuery , { } ) ;
556
- const snapshot = store . lookup ( operation . fragment ) ;
557
- const subscription = store . subscribe ( snapshot , cb ) ;
558
- // $FlowFixMe[unclear-type] - lookup() doesn't have the nice types of reading a fragment through the actual APIs:
559
- const { me} : any = snapshot . data ;
560
- expect ( me . constant_dependent ) . toEqual ( 1 ) ;
561
- environment . commitUpdate ( theStore => {
562
- const alice = nullthrows ( theStore . get ( '1' ) ) ;
563
- alice . setValue ( 'Alicia' , 'name' ) ;
564
- } ) ;
565
- subscription . dispose ( ) ;
558
+ const cb = jest . fn < [ Snapshot ] , void > ( ) ;
559
+ const operation = createOperationDescriptor ( FooQuery , { } ) ;
560
+ const snapshot = store . lookup ( operation . fragment ) ;
561
+ const subscription = store . subscribe ( snapshot , cb ) ;
562
+ // $FlowFixMe[unclear-type] - lookup() doesn't have the nice types of reading a fragment through the actual APIs:
563
+ const { me} : any = snapshot . data ;
564
+ expect ( me . constant_dependent ) . toEqual ( 1 ) ;
565
+ environment . commitUpdate ( theStore => {
566
+ const alice = nullthrows ( theStore . get ( '1' ) ) ;
567
+ alice . setValue ( 'Alicia' , 'name' ) ;
568
+ } ) ;
569
+ subscription . dispose ( ) ;
570
+
571
+ // Rereading the resolver's fragment, only to find that no fields that we read have changed,
572
+ // should clear the RELAY_RESOLVER_INVALIDATION_KEY.
573
+ const resolverCacheRecord = environment
574
+ . getStore ( )
575
+ . getSource ( )
576
+ . get ( 'client:1:constant_dependent' ) ;
577
+ invariant (
578
+ resolverCacheRecord != null ,
579
+ 'Expected a resolver cache record' ,
580
+ ) ;
566
581
567
- // Rereading the resolver's fragment, only to find that no fields that we read have changed,
568
- // should clear the RELAY_RESOLVER_INVALIDATION_KEY.
569
- const resolverCacheRecord = environment
570
- . getStore ( )
571
- . getSource ( )
572
- . get ( 'client:1:constant_dependent' ) ;
573
- invariant ( resolverCacheRecord != null , 'Expected a resolver cache record' ) ;
574
-
575
- const isMaybeInvalid = RelayModernRecord . getValue (
576
- resolverCacheRecord ,
577
- RELAY_RESOLVER_INVALIDATION_KEY ,
578
- ) ;
582
+ const isMaybeInvalid = RelayModernRecord . getValue (
583
+ resolverCacheRecord ,
584
+ RELAY_RESOLVER_INVALIDATION_KEY ,
585
+ ) ;
579
586
580
- // TODO(T185969900) This should actually be false since the reread of the fragment
581
- // should have reset the RELAY_RESOLVER_INVALIDATION_KEY flag.
582
- expect ( isMaybeInvalid ) . toBe ( true ) ;
583
- } ) ;
587
+ if ( markClean ) {
588
+ expect ( isMaybeInvalid ) . toBe ( false ) ;
589
+ } else {
590
+ // Without the feature flag enabled, T185969900 still reproduces.
591
+ expect ( isMaybeInvalid ) . toBe ( true ) ;
592
+ }
593
+ } ,
594
+ ) ;
584
595
585
596
it ( 'handles optimistic updates (applied after subscribing)' , ( ) => {
586
597
const source = RelayRecordSource . create ( {
0 commit comments