apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.75k stars 652 forks source link

Add apollo-runtime support for Linux target #3483

Open BoD opened 3 years ago

BoD commented 3 years ago

Apollo Android v3 doesn't currently target Linux.

milosmns commented 1 year ago

+1 over here.

It looks like most of the Kotlin/Native world is forced to use Ktor for client HTTP. On Linux, Ktor currently only supports cURL for networking, with CIO maybe to come later. So, with that in mind, I have 2 questions 😬

  1. Can Apollo runtime work on top of Ktor + cURL, which would then support all Kotlin/Native targets out of the box?

  2. What's the main blocker for runtime support on Linux, given that Mac is already supported?

Thanks! <3

martinbonnin commented 1 year ago

Hi @milosmns 🐧 👋

  1. Nope, apollo-runtime isn't compiled for linux at the moment so you can't make it work with cURL. You can though use apollo-api directly without apollo-runtime (documentation). It contains the parsers and everything you need to compose a query but not the actual HTTP client.

  2. I don't think there's a hard blocker, it's mostly a matter of prioritization and linux support hasn't been a focus lately. The main problem I can envision is that apollo-runtime currently expects a DefaultHttpEngine and I'd prefer we don't pull ktor in the dependencies by default. But I think starting with a placeholder HttpEngine that throws NotImplementedException would be fine. Then we'd need a separate ktor HttpEngine that users could register at runtime. Then we'd also need linuxArm64 maybe?

All in all, you can use linuxX64 today if you write the networking code yourself. Getting apollo-runtime to work will require some plumbing but it's certainly doable.

milosmns commented 1 year ago

Thanks for the quick response @martinbonnin!

Alright, makes sense, appreciate the update. I think that your proposal with a "not implemented" error on Linux should also work for the time being and would reduce the amount of plumbing needed for whoever wants to use this on Linux. But Linux for ARM is another beast altogether... not sure if even Ktor is supporting it, I'd need to check.