I might be just missing something but I don't see ...
# apollo-kotlin
f
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
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
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
You could have a
Copy code
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
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
OkHttpClient
implements
Call.Factory
so you can customize the
OkHttpClient
before creating the
ApolloHttpClient
before passing it to the
ApolloClient
Something like
Copy code
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
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
Yep, it's most likely "just" one target to add 🤞
Feel free to open an issue so we can track this
f
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
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
Sure, I'll create it now. Thanks again 👍 I am glad I discovered that you have this Slack channel.
👍 1
m
Sure thing! Thanks for looking into tvos !
f
m
A separate issue about logging for MPP if you want to subscribe: https://github.com/apollographql/apollo-android/issues/3107
f
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
@Filip Wiesner the problem is we need a released okio with tvos before we can release apollo
f
Yeah, sorry. I messaged too fast 😄 It's in master branch and now we just have to wait
m
Yep, everything has to propagate one after the other