Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    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.
    louiscad

    louiscad

    1 year ago
    If you have more details, I think @mbonnin might be able to help you as he's been working on it.
    mbonnin

    mbonnin

    1 year ago
    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
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    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.
    mbonnin

    mbonnin

    1 year ago
    Any chance your code is open source or can be shared? That'd be super helpful to debug
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    It is private unfortunatelly. But I will try to extract a part of it to demo project.
    Previously I sent wrong information. The request body from iOS build is not empty. Experimented with charles. On android (successful response):
    :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):
    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 👍
    louiscad

    louiscad

    1 year ago
    Why the Android app didn't have that issue? OkHttp adding the content-type by default?
    mbonnin

    mbonnin

    1 year ago
    Interesting, thanks for the follow up
    @Aleksandr Ivanov do you mind opening an issue, we should do the same for iOS
    louiscad

    louiscad

    1 year ago
    @mbonnin Can't it be put in common code to avoid forgetting it when adding support for more platforms?
    mbonnin

    mbonnin

    1 year ago
    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
    (Also I don't really want to depend on ktor for a simple use case like this)
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    Yep, will open it tomorrow. It is very confusing that it works differently.
    mbonnin

    mbonnin

    1 year ago
    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
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    I’m not very familiar with iOS development 🤷‍♂️
    mbonnin

    mbonnin

    1 year ago
    AH ok, I though you had it fixed on your side already, no problem, we'll make a fix
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    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.
    mbonnin

    mbonnin

    1 year ago
    Ah, got it! We want that to be in iOS code ultimately, I'll fix this
    Aleksandr Ivanov

    Aleksandr Ivanov

    1 year ago
    👌