apollographql / react-apollo

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

react-hooks throws a networkError if data is null #3574

Open mikestaub opened 5 years ago

mikestaub commented 5 years ago

Intended outcome:

I want to display the graphQL server errors to the client.

Actual outcome:

I see an opaque internal apollo error instead.

How to reproduce the issue:

Simply have your server return a response of the shape:

{
data: null,
errors: [{message:'some error'}]
}

and see the apollo error.

Version

System: OS: macOS Mojave 10.14.6 Binaries: Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node Yarn: 1.19.0 - ~/code/peapods.com/frontend/node_modules/.bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm Browsers: Chrome: 77.0.3865.90 Firefox: 68.0.2 Safari: 13.0.1 npmPackages: @apollo/react-hooks: 3.1.2 => 3.1.2 apollo: 2.15.0 => 2.15.0 apollo-cache-inmemory: 1.6.3 => 1.6.3 apollo-client: 2.6.4 => 2.6.4 apollo-graphql: 0.3.4 => 0.3.4 apollo-link-context: 1.0.19 => 1.0.19 apollo-link-debounce: 2.1.0 => 2.1.0 apollo-link-http: 1.5.16 => 1.5.16 apollo-link-persisted-queries: 0.2.2 => 0.2.2 apollo-storybook-react: 0.2.1 => 0.2.1

mikestaub commented 5 years ago

As a workaround, I am using the apollo-link-error package.