Is there anyone experienced with apollo graphql mu...
# multiplatform
a
Is there anyone experienced with apollo graphql multiplatform library? It is working fine on android but on iOS we got empty body on our backend.
l
If you have more details, I think @mbonnin might be able to help you as he's been working on it.
👀 1
m
Yup, we even have #apollo-android since a few days !
@Aleksandr Ivanov do you have more details? Does your backend receive an empty body or does it respond with an empty body?
In all cases, I would recommend setting up a Charles proxy to capture the traffic
a
Oh, Charles is a good idea. Will try it. Post body of the request is empty when came from iOS build. On Android it is working fine. Request is based on query defined in schema.
m
Any chance your code is open source or can be shared? That'd be super helpful to debug
a
It is private unfortunatelly. But I will try to extract a part of it to demo project.
👍 1
Previously I sent wrong information. The request body from iOS build is not empty. Experimented with charles. On android (successful response):
Copy code
:method: POST
:path: /graphql
:scheme: https

content-type: application/json; charset=utf-8
content-length: 316
accept-encoding: gzip
user-agent: okhttp/4.5.0
pragma: no-cache
cache-control: no-cache

{"operationName":"DriverSchedulePageQuery","variables":{"filter":{"from":"2020-10-15","to":"2020-10-29"}},"query":"query DriverSchedulePageQuery($filter: DateFilter!) { driverSchedule(filter: $filter) { __typename content { __typename date duties { __typename id driverShiftId type startAt endAt } } totalPages } }"}
on iOS (400 response):
Copy code
POST /graphql HTTP/1.1

Content-Type: application/x-www-form-urlencoded
User-Agent: Driver%20App/140 CFNetwork/1197 Darwin/19.6.0
Connection: keep-alive
Accept: */*
Accept-Language: en-us
Content-Length: 316
Accept-Encoding: gzip, deflate, br

{"operationName":"DriverSchedulePageQuery","variables":{"filter":{"from":"2020-10-15","to":"2020-10-29"}},"query":"query DriverSchedulePageQuery($filter: DateFilter!) { driverSchedule(filter: $filter) { __typename content { __typename date duties { __typename id driverShiftId type startAt endAt } } totalPages } }"}
The main difference I see is
Content-Type
Yes the problem was in the Content-Type. I manually set
content-type: application/json; charset=utf-8
and it works. Thank you for advice to use Charles 👍
l
Why the Android app didn't have that issue? OkHttp adding the content-type by default?
m
Interesting, thanks for the follow up
@Aleksandr Ivanov do you mind opening an issue, we should do the same for iOS
l
@mbonnin Can't it be put in common code to avoid forgetting it when adding support for more platforms?
m
We could put the string constant in common code but the way to set the headers is different on iOS and Android so some of it would have to be duplicated anyways
☝️ 1
(Also I don't really want to depend on ktor for a simple use case like this)
a
Yep, will open it tomorrow. It is very confusing that it works differently.
🙏 1
m
Thanks you so much ! If you have the iOS code at hand, a PR is very welcome, if not, I'll fix this somewhere next week
a
I’m not very familiar with iOS development 🤷‍♂️
m
AH ok, I though you had it fixed on your side already, no problem, we'll make a fix
a
I fixed it in multiplatform code writen in kotlin by manually adding header to ApolloClient. If it is how it should be fixed in library I could do that. Just point me to right module to look into.
m
Ah, got it! We want that to be in iOS code ultimately, I'll fix this
a
👌