@@ -377,6 +377,111 @@ it.each([["cache-first"], ["no-cache"]] as const)(
377377 }
378378) ;
379379
380+ test . failing (
381+ 'returns non-deferred cached data with a "cache-first" fetch policy and returnPartialData: false' ,
382+ async ( ) => {
383+ const query = gql `
384+ query {
385+ greeting {
386+ message
387+ ... on Greeting @defer {
388+ recipient {
389+ name
390+ email
391+ }
392+ }
393+ }
394+ }
395+ ` ;
396+
397+ const { httpLink, enqueueInitialChunk, enqueueSubsequentChunk } =
398+ mockDeferStreamGraphQL17Alpha9 ( ) ;
399+ const cache = new InMemoryCache ( ) ;
400+
401+ // We are intentionally writing partial data to the cache. Suppress console
402+ // warnings to avoid unnecessary noise in the test.
403+ {
404+ using _consoleSpy = spyOnConsole ( "error" ) ;
405+ cache . writeQuery ( {
406+ query,
407+ data : {
408+ greeting : {
409+ __typename : "Greeting" ,
410+ recipient : {
411+ email : "test@example.com" ,
412+ } ,
413+ } ,
414+ } ,
415+ } ) ;
416+ }
417+
418+ const client = new ApolloClient ( {
419+ cache,
420+ link : httpLink ,
421+ incrementalHandler : new GraphQL17Alpha9Handler ( ) ,
422+ } ) ;
423+
424+ const stream = new ObservableStream ( client . watchQuery ( { query } ) ) ;
425+
426+ await expect ( stream ) . toEmitTypedValue ( {
427+ data : undefined ,
428+ dataState : "empty" ,
429+ loading : true ,
430+ networkStatus : NetworkStatus . loading ,
431+ partial : true ,
432+ } ) ;
433+
434+ enqueueInitialChunk ( {
435+ data : { greeting : { message : "Hello world" , __typename : "Greeting" } } ,
436+ pending : [ { id : "0" , path : [ "greeting" ] } ] ,
437+ hasNext : true ,
438+ } ) ;
439+
440+ await expect ( stream ) . toEmitTypedValue ( {
441+ data : markAsStreaming ( {
442+ greeting : {
443+ __typename : "Greeting" ,
444+ message : "Hello world" ,
445+ } ,
446+ } ) ,
447+ dataState : "streaming" ,
448+ loading : true ,
449+ networkStatus : NetworkStatus . streaming ,
450+ partial : true ,
451+ } ) ;
452+
453+ enqueueSubsequentChunk ( {
454+ incremental : [
455+ {
456+ data : {
457+ __typename : "Greeting" ,
458+ recipient : { name : "Alice" , __typename : "Person" } ,
459+ } ,
460+ id : "0" ,
461+ } ,
462+ ] ,
463+ completed : [ { id : "0" } ] ,
464+ hasNext : false ,
465+ } ) ;
466+
467+ await expect ( stream ) . toEmitTypedValue ( {
468+ data : {
469+ greeting : {
470+ __typename : "Greeting" ,
471+ message : "Hello world" ,
472+ recipient : { __typename : "Person" , name : "Alice" } ,
473+ } ,
474+ } ,
475+ dataState : "complete" ,
476+ loading : false ,
477+ networkStatus : NetworkStatus . ready ,
478+ partial : false ,
479+ } ) ;
480+
481+ await expect ( stream ) . not . toEmitAnything ( ) ;
482+ }
483+ ) ;
484+
380485test ( 'returns partial non-deferred cached data with a "cache-first" fetch policy and returnPartialData' , async ( ) => {
381486 const query = gql `
382487 query {
0 commit comments