https://kotlinlang.org logo
h

Hossein Amini

08/08/2021, 5:13 AM
Hi, how can I use GraphQL in KMM projects. Because Apollo requires iOS 13+ we’re looking for an alternative.
m

mbonnin

08/08/2021, 8:10 AM
Do you need subscriptions ? iOS 13 is only required for WebSockets. It might work if you don't use subscriptions. Worst case, we could move websockets to a separate module
h

Hossein Amini

08/08/2021, 9:10 AM
Yeah, websocket will be used heavily in the project. Is there any libraries to convert data models to GraphQL queries? If we want to use Ktor instead of Apollo
m

mbonnin

08/08/2021, 9:25 AM
Can Ktor do WebSocket on iOS ? Reading https://ktor.io/docs/websocket-client.html#usage I'm not sure
h

Hossein Amini

08/08/2021, 9:42 AM
You’re right, relating to this issue https://github.com/ktorio/ktor/issues/1894 it doesn’t support websocket on iOS. Is there any alternative way?
m

mbonnin

08/08/2021, 10:06 AM
If you need subscriptions on iOS < 13, you'll have to write your own WebSockets code. Either using plain C sockets or maybe linking with starscream, a WebSocket library on iOS
h

Hossein Amini

08/08/2021, 10:28 AM
m

mbonnin

08/08/2021, 11:16 AM
This is what Apollo Android does. It requires iOS 13
h

Hossein Amini

08/08/2021, 12:12 PM
Why it's not compatible with iOS < 13? According to the apple docs NSURLSession is available on iOS 7.0+ https://developer.apple.com/documentation/foundation/nsurlsession
h

Hossein Amini

08/09/2021, 1:15 AM
Right, thanks 🙏
5 Views