@@ -5984,6 +5984,110 @@ test('does not return complete cached deferred data while streaming with a "netw
59845984 await expect ( stream ) . not . toEmitAnything ( ) ;
59855985} ) ;
59865986
5987+ test ( 'does not return complete cached deferred data when a defer boundary completes with errors with a "network-only" fetch policy' , async ( ) => {
5988+ const query = gql `
5989+ query {
5990+ greeting {
5991+ message
5992+ ... on Greeting @defer {
5993+ recipient {
5994+ name
5995+ }
5996+ }
5997+ }
5998+ }
5999+ ` ;
6000+
6001+ const { httpLink, enqueueInitialChunk, enqueueSubsequentChunk } =
6002+ mockDeferStreamGraphQL17Alpha9 ( ) ;
6003+ const cache = new InMemoryCache ( ) ;
6004+
6005+ cache . writeQuery ( {
6006+ query,
6007+ data : {
6008+ greeting : {
6009+ __typename : "Greeting" ,
6010+ message : "Cached hello" ,
6011+ recipient : { __typename : "Person" , name : "Cached Alice" } ,
6012+ } ,
6013+ } ,
6014+ } ) ;
6015+
6016+ const client = new ApolloClient ( {
6017+ cache,
6018+ link : httpLink ,
6019+ incrementalHandler : new GraphQL17Alpha9Handler ( ) ,
6020+ } ) ;
6021+
6022+ const stream = new ObservableStream (
6023+ client . watchQuery ( {
6024+ query,
6025+ fetchPolicy : "network-only" ,
6026+ errorPolicy : "all" ,
6027+ } )
6028+ ) ;
6029+
6030+ await expect ( stream ) . toEmitTypedValue ( {
6031+ data : undefined ,
6032+ dataState : "empty" ,
6033+ loading : true ,
6034+ networkStatus : NetworkStatus . loading ,
6035+ partial : true ,
6036+ } ) ;
6037+
6038+ enqueueInitialChunk ( {
6039+ data : { greeting : { __typename : "Greeting" , message : "Hello world" } } ,
6040+ pending : [ { id : "0" , path : [ "greeting" ] } ] ,
6041+ hasNext : true ,
6042+ } ) ;
6043+
6044+ await expect ( stream ) . toEmitTypedValue ( {
6045+ data : markAsStreaming ( {
6046+ greeting : { __typename : "Greeting" , message : "Hello world" } ,
6047+ } ) ,
6048+ dataState : "streaming" ,
6049+ loading : true ,
6050+ networkStatus : NetworkStatus . streaming ,
6051+ partial : true ,
6052+ } ) ;
6053+
6054+ enqueueSubsequentChunk ( {
6055+ completed : [
6056+ {
6057+ id : "0" ,
6058+ errors : [
6059+ {
6060+ message : "Could not fetch recipient" ,
6061+ path : [ "greeting" , "recipient" ] ,
6062+ } ,
6063+ ] ,
6064+ } ,
6065+ ] ,
6066+ hasNext : false ,
6067+ } ) ;
6068+
6069+ await expect ( stream ) . toEmitTypedValue ( {
6070+ data : markAsStreaming ( {
6071+ greeting : { __typename : "Greeting" , message : "Hello world" } ,
6072+ } ) ,
6073+ dataState : "streaming" ,
6074+ error : new CombinedGraphQLErrors ( {
6075+ data : { greeting : { __typename : "Greeting" , message : "Hello world" } } ,
6076+ errors : [
6077+ {
6078+ message : "Could not fetch recipient" ,
6079+ path : [ "greeting" , "recipient" ] ,
6080+ } ,
6081+ ] ,
6082+ } ) ,
6083+ loading : false ,
6084+ networkStatus : NetworkStatus . error ,
6085+ partial : true ,
6086+ } ) ;
6087+
6088+ await expect ( stream ) . not . toEmitAnything ( ) ;
6089+ } ) ;
6090+
59876091test ( 'does not return a partial cached defer boundary while streaming with a "network-only" fetch policy' , async ( ) => {
59886092 const query = gql `
59896093 query {
0 commit comments