File tree Expand file tree Collapse file tree
src/cache/inmemory/__tests__/cache.diff Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,55 @@ test("returns FieldResult failure for a field with @catch(to: RESULT) when the f
9494 } ) ;
9595} ) ;
9696
97+ test ( "defaults bare @catch to RESULT and does not inherit @catchByDefault" , ( ) => {
98+ const cache = new InMemoryCache ( ) ;
99+ const query = gql `
100+ query UserQuery @catchByDefault(to: THROW) {
101+ user {
102+ id
103+ name @catch
104+ }
105+ }
106+ ` ;
107+
108+ cache . writeQuery ( {
109+ query,
110+ data : {
111+ user : {
112+ __typename : "User" ,
113+ id : "1" ,
114+ name : null ,
115+ } ,
116+ } ,
117+ errors : [
118+ {
119+ message : "Cannot resolve user.name" ,
120+ path : [ "user" , "name" ] ,
121+ } ,
122+ ] ,
123+ } ) ;
124+
125+ expect ( cache . diff ( { query, optimistic : false } ) ) . toStrictEqualTyped ( {
126+ result : {
127+ user : {
128+ __typename : "User" ,
129+ id : "1" ,
130+ name : {
131+ ok : false ,
132+ errors : [
133+ {
134+ message : "Cannot resolve user.name" ,
135+ path : [ "user" , "name" ] ,
136+ } ,
137+ ] ,
138+ } ,
139+ } ,
140+ } ,
141+ complete : true ,
142+ missing : undefined ,
143+ } ) ;
144+ } ) ;
145+
97146test ( "throws for a field with @catch(to: THROW) when the field has a path error" , ( ) => {
98147 const cache = new InMemoryCache ( ) ;
99148 const query = gql `
You can’t perform that action at this time.
0 commit comments