You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a query using useQuery you get an object containing the onResult function. Using this function you can register function to be called - well - on a result I thought. Following the typings, I happily went on, until I discovered that the data property sometimes is null ... which - according to the docs (https://www.apollographql.com/docs/react/data/queries/#result) - should only happen if the value is set to another value but none. According to the docs, none is the default value, which seems to be different on this package.
'Cause they do have a difference if the property errorPolicy is set or not. I've tested it, and in my tests this property was undefined, which is why I get a call on my function registered at onResult.
To Reproduce
const{ onResult }=useQuery(gql` { queryThatDoesNotExistOnTheServer } `,// { errorPolicy: "none" } // <-- Apply this line and you'll see that the function registered at onResult is not called);onResult((queryResult)=>{console.log(queryResult)});
Describe the bug
When running a query using
useQuery
you get an object containing theonResult
function. Using this function you can register function to be called - well - on a result I thought. Following the typings, I happily went on, until I discovered that thedata
property sometimes is null ... which - according to the docs (https://www.apollographql.com/docs/react/data/queries/#result) - should only happen if the value is set to another value butnone
. According to the docs,none
is the default value, which seems to be different on this package.I suspect these lines here to be responsible:
apollo/packages/vue-apollo-composable/src/useQuery.ts
Lines 287 to 289 in 63675b6
'Cause they do have a difference if the property
errorPolicy
is set or not. I've tested it, and in my tests this property wasundefined
, which is why I get a call on my function registered atonResult
.To Reproduce
Expected behavior
The function registered at
onResult
should only be called if there is a valid result - as described in the manual: https://v4.apollo.vuejs.org/guide-composable/error-handling.html#error-handlingIn fact, if I explicitly set the
errorPolicy
tonone
, it works as expected.Versions
vue:
3.2.29
@vue/apollo-composable:
4.0.0-alpha.16
@apollo/client:
3.5.8
Additional context
Is there any way to set a general errorPolicy for all queries?
The text was updated successfully, but these errors were encountered: