Closed dmarkow closed 4 years ago
Thanks for pointing this out @dmarkow. If you (or anyone else) is interested in submitting a PR to address this in the AC 3 codebase (master
of this repo), we'll get it in. Thanks!
@hwillson apollo-link-http
has a dependency on apollo-link-http-common
to provide the ServerError
and ServerParseError
types. Would it be preferable to introduce the same dependency in apollo-client
or to just paste in the types?
@dmarkow AC3 should already have ServerError
and ServerParseError
types in the codebase (although they are a bit all over the place):
If you can use those types, that would be great - thanks!
Presumably, the error that
apollo-client
raises and the error passed intoapollo-link-error
are the same. However, thenetworkError
keys don't match up.apollo-link-error
correctly usesError | ServerError | ServerParseError
whereasapollo-client
just usesError
.This means that accessing things like
networkError.statusCode
isn't possible on the error raised byapollo-client
without casting it to a different type first.Intended outcome: Be able to access things like
networkError?.statusCode
on the error object.Actual outcome:
networkError
is typed asError | null
so you can't access status codes, etc.How to reproduce the issue:
I ran into this by trying to work with the error object:
Versions System: OS: macOS 10.15.3 Binaries: Node: 12.16.2 - ~/.volta/tools/image/node/12.16.2/6.14.4/bin/node Yarn: 1.22.4 npm: 6.14.4 - ~/.volta/tools/image/node/12.16.2/6.14.4/bin/npm Browsers: Chrome: 81.0.4044.138 Safari: 13.0.5 npmPackages: @apollo/react-hooks: 3.1.5 => 3.1.5 apollo: ^2.27.4 => 2.27.4 apollo-cache: ^1.3.5 => 1.3.5 apollo-cache-inmemory: 1.6.6 => 1.6.6 apollo-client: 2.6.10 => 2.6.10 apollo-fetch: ^0.7.0 => 0.7.0 apollo-link: ^1.2.14 => 1.2.14 apollo-link-batch-http: ^1.2.14 => 1.2.14 apollo-link-error: ^1.1.13 => 1.1.13 apollo-link-http: ^1.5.17 => 1.5.17 apollo-utilities: ^1.3.4 => 1.3.4 react-apollo: 3.1.5 => 3.1.5