apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 790 forks source link

when status code is 403, client.query => graphqlError, graphql hoc => networkError #4041

Closed wukong1995 closed 4 years ago

wukong1995 commented 4 years ago

when I in server set status code is 403, and throw error

I get result in chrome network

data: { xxx: null }
errors: [{xxxx}]

when I use client.query, I get graphqlError

// data.js
const getData = () => return client.query(xxxx)

// apollo.util.js
const errorLink = onError(({ networkError, graphQLErrors }) => {
   console.log(graphQLErrors, networkError) // output: {data: xxx, errors: xxxx},  undefined
})

when I use graphql hoc, I get networkError

// data.js
const getData = graphql(xxxxx)

// apollo.util.js
const errorLink = onError(({ networkError, graphQLErrors }) => {
   console.log(graphQLErrors, networkError) // output: undefined, { statusCode: 403, result: xxxx, ...}
})

Version

"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-context": "^1.0.20",
"apollo-link-error": "^1.1.13",
"apollo-link-http": "^1.5.17",
"graphql": "^15.3.0",
"graphql-tag": "^2.10.3",
"react-apollo": "^2.5.8",
wukong1995 commented 4 years ago

I try upgrade v3

wukong1995 commented 4 years ago

i find Deprecated React Apollo HOC API, so i close this issue.