Apollo types the networkError property on ApolloError as Error | null which is kinda tragic. This is my initial exploration at fleshing things out. In an ideal world, network error would be something like this: https://github.com/elm/http/blob/2.0.0/src/Http.elm#L538
type Error
= BadUrl String
| Timeout
| NetworkError
| BadStatus Int
| BadBody String
Unfortunately we don't have much ability to get this information after the fact. The types in @apollo/link-error are better: Error | ServerError | ServerParseError So tried working with that. It's wasn't clear to me from those names what they actually mean without digging into the internals of Apollo. If I were to rename them I'd do something like this:
type networkError =
| FetchFailure(Js.Exn.t)
| BadStatus(int, ServerError.t)
| BadBody(ServerParseError.t)
Right now, I've messily pulled the types from the link-error bindings over and kept the names of the variants the same (Error | ServerError | ServerParseError), but I'm curious what anyone thinks of renaming the variants. This is one of the first cases where we're diverging from the TypeScript types, so I'm actually leaning that direction.
Apollo types the
networkError
property onApolloError
asError | null
which is kinda tragic. This is my initial exploration at fleshing things out. In an ideal world, network error would be something like this: https://github.com/elm/http/blob/2.0.0/src/Http.elm#L538Unfortunately we don't have much ability to get this information after the fact. The types in
@apollo/link-error
are better:Error | ServerError | ServerParseError
So tried working with that. It's wasn't clear to me from those names what they actually mean without digging into the internals of Apollo. If I were to rename them I'd do something like this:Right now, I've messily pulled the types from the
link-error
bindings over and kept the names of the variants the same (Error | ServerError | ServerParseError
), but I'm curious what anyone thinks of renaming the variants. This is one of the first cases where we're diverging from the TypeScript types, so I'm actually leaning that direction.