I’m looking for references on Apollo best practice...
# apollo-kotlin
m
I’m looking for references on Apollo best practices such as error handling, repository patterns etc. However, I’m having a hard time finding any extensive samples on GitHub as most seem to have only a couple of queries and rudimentary error handling. Are there any extensive open source apollo-kotlin client project available?
plus1 1
m
m
Ohhh right!!! Forgot about this one from @Stylianos Gakis, it is pretty extensive indeed 👍
s
Heh yes that’s us! Not sure about if our repo is the golden standard of best practices (far from it) but it definitely is extensive, we use apollo-koltin for all networking and our app is indeed basically all about getting stuff from the internet, not much local logic. For error handling one thing I’ve personally enjoyed doing has been this. Using some
safe
alternatives built on-top of the apollo functions like safeQuery (yes the name should be changed since it’s an extension on ApolloCall which accepts more than just queries, but gonna refactor that some day 😄 ) which turns exceptions into a typed result and then we’ve recently-ish added a toEither extension to that so that error handling on the client side can take the #arrow shape as I like to think about it. Example #1, #2, #3, #4.
I wonder how you found our repo btw, was it from this channel or did you search someplace else?
m
Noticed the
safeQuery
extension as well. I tried to see if you do more granular error handling , such as dealing with 401 /
Unauthorized
but I guess you don’t treat those specifically?
I think I’m gonna start another thread on the topic of 401 and handling errors
s
No we do not do anything special there, our error handling is just what you see there, a simple failed/succeeded, not too sophisticated for sure.