Any reason why Apollo client ( v3.7.4) throws Apol...
# apollo-kotlin
p
Any reason why Apollo client ( v3.7.4) throws ApolloNetworkException when response code is 401
m
What would you expect instead?
p
I could handle it or AuthException
m
i'd recommend you handle this at the HttpInterceptor level
p
I just wanted to understand the rational. I am already working with it.
m
This way you can retry transparently
p
That make sense.
m
All exceptions inherit from ApolloExcption so that it's easier to know what can happen
I'm not even sure there's a MPP AuthException?
p
There isn't . I meant something on those lines .. ApolloAuthException
m
Some servers handle auth at the GraphQl layer
There's no concept of Authentication in GraphQL, it's a HTTP thing really
It's all server dependant
p
I agree. I guess only way to propagate 401 is throwing exception and it makes more sense to handle it at HttpInterceptor level since it is actually HTTP thing
m
Exactly!
I think if you really want to you should be able to get the HTTP code from the ApolloNetworkException (there should be a ApolloHttpException somewhere in 'cause' or so that contains the status code)
Not 100% sure about the details as I'm on mobile right now but in all cases, HTTP is the good place to handle this
p
Yes. I am going to handle at Http level. Thank you for your inputs Martin.
m
Sure thing!