https://kotlinlang.org logo
Title
f

Filip Wiesner

05/10/2021, 7:40 PM
I might be just missing something but I don't see a way to log network traffic with Apollo multiplatform. It's pretty easy with access to OkHttp interceptor but I don't think I am able to do that from common code.
m

mbonnin

05/10/2021, 8:01 PM
Yea, not much. Is this for debug or something else?
You can use
expect
/`actual` if needed . The JVM
ApolloHttpNetworkTransport
takes a
OkHttpClient
so you can use interceptors there. And on iOS, it takes a
DataTaskFactory
where you can intercept requests if needed
f

Filip Wiesner

05/10/2021, 8:40 PM
Yeah, for debug. I am used to using Flipper with OkHttp. You mean making my own
NetworkTransport
copying the Apollo code and adding my interceptor? Or what do you mean by "_use 
expect
 /`actual` if needed_".
m

mbonnin

05/10/2021, 8:42 PM
You could have a
expect CustomNetworkTransport
that delegates to
ApolloHttpNetworkTransport
It's going to be more boiler plate but it should work
Also, is there's something like
Flipper
on iOS? Or are you looking at replacing Flipper with stdout ?
f

Filip Wiesner

05/10/2021, 8:47 PM
I am not iOS dev so I am not sure 😅 I think there is
Atlantis
for iOS but I don't know anything about it.
m

mbonnin

05/10/2021, 8:47 PM
OkHttpClient
implements
Call.Factory
so you can customize the
OkHttpClient
before creating the
ApolloHttpClient
before passing it to the
ApolloClient
Something like
val client = ApolloClient(
  networkTransport = ApolloHttpNetworkTransport(
    serverUrl = "https://",
    headers = Headers.of(emptyMap()),
    httpCallFactory = OkHttpClient.Builder()
         .addInterceptor(...)
         .build() 
  )
)
Of course that doesn't work on ios
f

Filip Wiesner

05/10/2021, 8:53 PM
I see what you mean. I'll just have to bend it a bit to make it work. Thanks a lot 👌 One more unrelated question when I am talking to you. Would you consider adding
tvOS
target? From what I've seen you would "only" need tvOS added to Okio lib (there is already issue for it) and than it's just adding the build target.
m

mbonnin

05/10/2021, 8:54 PM
Yep, it's most likely "just" one target to add 🤞
Feel free to open an issue so we can track this
f

Filip Wiesner

05/10/2021, 8:58 PM
Yeah, we (with a colleague) wanted to make issue when the Okio is ready but I can do it now if you want to. We need it now so we've forked it and made it work and it's not hard (so far.. 😅 ). Only the Okio is the problem so we needed to fork it too.
m

mbonnin

05/10/2021, 8:58 PM
Yep, dependencies all the way down 😅
Opening an issue is always good, maybe someone else will need it and having the context and the link to the okio issue will help
f

Filip Wiesner

05/10/2021, 9:00 PM
Sure, I'll create it now. Thanks again 👍 I am glad I discovered that you have this Slack channel.
👍 1
m

mbonnin

05/10/2021, 9:00 PM
Sure thing! Thanks for looking into tvos !
f

Filip Wiesner

05/10/2021, 9:08 PM
m

mbonnin

05/17/2021, 8:08 AM
A separate issue about logging for MPP if you want to subscribe: https://github.com/apollographql/apollo-android/issues/3107
f

Filip Wiesner

05/17/2021, 8:09 AM
Nice, thank you 🙌
The Okio issue has been closed and tvOS target added. Can we expect Apollo to add tvOS target now as well? @mbonnin
Ooops, I see you already know about this and and liked the tvOS pull request. Sorry for the ping
m

mbonnin

05/27/2021, 4:11 PM
@Filip Wiesner the problem is we need a released okio with tvos before we can release apollo
f

Filip Wiesner

05/27/2021, 4:13 PM
Yeah, sorry. I messaged too fast 😄 It's in master branch and now we just have to wait
m

mbonnin

05/27/2021, 4:17 PM
Yep, everything has to propagate one after the other