I'm new to kotlin, and created a sample Multiplatf...
# multiplatform
v
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
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
TIL the official guide is old
k
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
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
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
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
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
@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
ktor is multiplatform
v
yes but only for http call, what about graphql?
k
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
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
I'm working on a graphql kotlin generator thingy magick but don't hold your breath.
k
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
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
It's from the future, just like Kotlin Multiplatform.
k
Something’s up with the dates and caches. Assuming the site runs on kotlin, need a solid date library!
🤣 1