I have aproblem when test Apollo.When I try query with apollo and graphql, i want response return error and partical data, so I set property errorPolicy:'all'. But its not work. I don't no why? Help please! Here my code:
query { animal { name age }, school { name numberfd } } `
const { loading,data,error} = useQuery(GET_DASHBOARD_DATA, { errorPolicy:'all', onCompleted: (res) => {console.log("complete",res)}, onError : (res,data) => {console.log("ERRRR",res,data)}, })
and i want to receive:
{ error:[...], data:[animal:[...]] }
but its only response error.Here is Apollo's doc: https://www.apollographql.com/docs/react/data/error-handling/
I faced the same issue with
errorPolicy: 'all'
, I only received the partial result insideonCompleted
callback ofuseQuery
, but no errors.I created an
ErrorLink
like this:Now inside my
onCompleted
callback I get my data as well aserrors
. You will have to tweak your types a bit, because seems there is noerrors
field on response.data by default.