Apollo-client: Query component, if there is graphql error, data is totally empty, even if http request returns some valid data

Created on 30 May 2018  路  3Comments  路  Source: apollographql/apollo-client

Intended outcome:

Use Query component to get data

Actual outcome:
data in callback child render function is empty when there is graphql error for one key, but not all. If you inspect the http request, there are some valid data in 'data' field.

How to reproduce the issue:
Use Query component, to query several data fields, throw one error in one resolver, and keep other fields return valid data.

Versions

"react-apollo": "^2.1.3",

blocking

Most helpful comment

@nicolasxu-bg I think this is a react-apollo issue more than apollo-client, but try adding errorPolicy="all" to your Query component:

<Query errorPolicy="all" ...etc />

That should give you the most data despite errors inside some of the resolvers, etc.

Read more: https://www.apollographql.com/docs/react/features/error-handling.html#policies

All 3 comments

@nicolasxu-bg I think this is a react-apollo issue more than apollo-client, but try adding errorPolicy="all" to your Query component:

<Query errorPolicy="all" ...etc />

That should give you the most data despite errors inside some of the resolvers, etc.

Read more: https://www.apollographql.com/docs/react/features/error-handling.html#policies

(This issue can probably be closed.)

See the solution mentioned in https://github.com/apollographql/apollo-client/issues/3529#issuecomment-393389772 (thanks @jasonrhodes!).

Was this page helpful?
0 / 5 - 0 ratings