https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
v

Vishal

08/08/2019, 5:00 AM
I'm new to kotlin, and created a sample Multiplatform application(common code will be shared between Android and IOS) using https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html#creating-an-android-project reference. Everything is working fine, now i need to write common code for calling graphql API that can be used from both Android and IOS. Can anybody help?
k

kpgalligan

08/08/2019, 12:43 PM
I would start with a newer tutorial. That is quite old. I’m not sure what the best/most current one is. We have one in the queue that’s essentially “get started in 5 minutes” for native mobile. Need to check with the team on where that is and may be able to share that a little later.
For graphql, there is no multiplatform library (that I’m aware of). You’ll need to construct the calls manually and use ktor (or similar).
s

saket

08/08/2019, 12:45 PM
TIL the official guide is old
k

kpgalligan

08/08/2019, 12:48 PM
Well, one of the official guides is old. That’s last kotlinconf, which in KMP terms is pretty old. Try this: https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html
Wait, weird!
That’s really odd
Never mind. Seems hard to believe, but either something really strange is happening server side, or I had a really old cached version (and this laptop is newer than Oct 2018). In any case, it’s not as old as it appeared.
The content I was seeing was old, though. Talking about 1.3.21, etc
s

saket

08/08/2019, 1:31 PM
Interesting. I'm still seeing 1.3.21 on my side. Let me check another browser.
Yep, it is a caching issue. Thanks for the headsup Kevin!
k

kpgalligan

08/08/2019, 1:33 PM
Weird, right?
I think if you saw that and I saw that, either they just updated it, or something on the back end wasn’t working
v

Vishal

08/08/2019, 3:34 PM
Hi @kpgalligan can you help me with creating a multiplatform library for calling graphql API that can be used by both IOS and Android
k

kpgalligan

08/08/2019, 3:38 PM
I have zero graghql experience. You’ll either need to create your own server calls, or try to expect/actual apollo android and ios (or something similar). Not sure that’s possible, though. If apollo does code gen, expect/actual may be difficult.
v

Vishal

08/08/2019, 3:43 PM
@kpgalligan but apollo is only for android and i want something that can be used by both IOS and Android
@saket but ktor is kotlin library for calling the graphql APIs from android only, right? how can i achieve something which can be used by both Android and IOS
k

kpgalligan

08/08/2019, 3:48 PM
ktor is multiplatform
v

Vishal

08/08/2019, 3:50 PM
yes but only for http call, what about graphql?
k

kpgalligan

08/08/2019, 3:54 PM
You need to either create your graphql calls manually with ktor, or try to expect/actual with apollo android and iOS. There is no multiplatform graphql library. I mean, that’s the answer. Creating a multiplatform version of apollo is something we’re discussing (quite literally right now), but if that happens it’ll be a while.
y

yshrsmz

08/09/2019, 9:49 AM
GraphQL is just a http POST, so you can do it manually if you choose. FYI this is my attempt to create Kotlin wrapper for GraphQL reequest body https://github.com/yshrsmz/kgql
d

Dominaezzz

08/09/2019, 3:03 PM
I'm working on a graphql kotlin generator thingy magick but don't hold your breath.
k

kpgalligan

08/09/2019, 3:13 PM
If I get time I’m going to start looking at apollo, but not sure we’re actually going to dive into implementing that. There’s been talk about it recently: https://github.com/apollographql/apollo-android/issues/1455
👍 1
r

russhwolf

08/09/2019, 4:01 PM
Poking in late but I hadn't seen that the MPP Android/iOS tutorial had updated. Loving that the update date is two days from now 🙃
🤣 1
s

saket

08/09/2019, 4:09 PM
It's from the future, just like Kotlin Multiplatform.
k

kpgalligan

08/09/2019, 6:25 PM
Something’s up with the dates and caches. Assuming the site runs on kotlin, need a solid date library!
🤣 1
3 Views