@@ -7,7 +7,6 @@ import type {
77 Cache ,
88 DiffIncrementalInfo ,
99 IgnoreModifier ,
10- InMemoryCache ,
1110} from "@apollo/client/cache" ;
1211import type { Incremental } from "@apollo/client/incremental" ;
1312import type { ApolloLink } from "@apollo/client/link" ;
@@ -390,12 +389,12 @@ export class QueryInfo<
390389 networkStatus !== NetworkStatus . refetch ;
391390
392391 const { dataState, result : diffResult } = this . getDiff (
393- {
394- ... diffOptions ,
392+ diffOptions ,
393+ this . getIncrementalInfo ( result , {
395394 // Never deliver partial data for network-only requests
396395 returnPartialData : returnPartialData && ! isNetworkOnly ,
397- } ,
398- this . getIncrementalInfo ( result , { isNetworkOnly } )
396+ isNetworkOnly ,
397+ } )
399398 ) ;
400399
401400 if (
@@ -416,11 +415,17 @@ export class QueryInfo<
416415
417416 private getIncrementalInfo (
418417 result : MarkQueryResult < any , ExtensionsWithStreamInfo > ,
419- { isNetworkOnly } : { isNetworkOnly : boolean }
418+ {
419+ isNetworkOnly,
420+ returnPartialData,
421+ } : { isNetworkOnly : boolean ; returnPartialData : boolean | undefined }
420422 ) {
421423 const pending = this . incremental ?. pending ?? [ ] ;
422424 const streamInfo = result . extensions ?. [ streamInfoSymbol ] ?. deref ( ) ;
423- const incrementalInfo : DiffIncrementalInfo = { streamInfo } ;
425+ const incrementalInfo : DiffIncrementalInfo = {
426+ streamInfo,
427+ returnPartialData,
428+ } ;
424429
425430 // We don't want to deliver stream items or complete defer boundaries
426431 // for a network-only request if they haven't yet streamed from the
@@ -446,19 +451,22 @@ export class QueryInfo<
446451 options : Cache . DiffOptions < TData > ,
447452 incrementalInfo ?: DiffIncrementalInfo
448453 ) : Cache . InternalDiffResultWithDataState < TData > {
449- if ( ( this . cache as any ) [ handleIncrementalSymbol ] ) {
450- return ( this . cache as unknown as InMemoryCache ) . diff ( {
451- ...options ,
452- [ handleIncrementalSymbol ] : incrementalInfo || true ,
453- } ) ;
454+ const diff = this . cache . diff ( {
455+ ...options ,
456+ // returnPartialData is overridden for backwards compatibility with caches
457+ // that don't handle incremental results. Without this, in-flight
458+ // incremental cache data would come back null when returnPartialData is
459+ // false due to the partial result.
460+ returnPartialData : true ,
461+ [ handleIncrementalSymbol ] : incrementalInfo || {
462+ returnPartialData : options . returnPartialData ,
463+ } ,
464+ } ) ;
465+
466+ if ( "dataState" in diff ) {
467+ return diff ;
454468 }
455469
456- // returnPartialData is overridden for backwards compatibility with caches
457- // that don't handle incremental results. Without this, in-flight
458- // incremental cache data would come back null when returnPartialData is
459- // false due to the partial result.
460- const diff = this . cache . diff ( { ...options , returnPartialData : true } ) ;
461-
462470 return {
463471 ...diff ,
464472 dataState :
0 commit comments