Emil Butiri
08/17/2023, 12:56 PMAccept-Encoding: gzip
header, first on the OkHttpClient
, then on the ApolloClient
, but neither solution worked, as requests fail with JsonEncodingException
because of “malformed JSON”. Tried the same with the 2 sample apps mentioned in the docs. MortyComposeKMM has the same issue, while the apollo-kotlin-tutorial app works no matter if I set the header on the Http client or the Apollo client.Emil Butiri
08/17/2023, 12:56 PMOkHttpClient
configured in the app
module (because of a migration in progress and a mix of REST and graphQL backends). I should mention that our iOS app (which at the moment is completely separate) works with gzip
without issues.Emil Butiri
08/17/2023, 1:02 PMprivate val apolloClient = ApolloClient.Builder()
.serverUrl("<https://rickandmortyapi.com/graphql>")
.addHttpInterceptor(
HeadersInterceptor(listOf(HttpHeader("Accept-Encoding", "gzip")))
)
.addHttpInterceptor(LoggingInterceptor())
.build()
mbonnin
08/17/2023, 1:28 PMEmil Butiri
08/17/2023, 1:32 PMHttpLoggingInterceptor
) will print the unzipped JSON, while the Apollo LoggingInterceptor
will print the binary contentEmil Butiri
08/17/2023, 1:32 PMEmil Butiri
08/17/2023, 1:59 PMRequest headers:
Content-Type: application/json
Content-Length: 164
X-APOLLO-OPERATION-ID: ...
X-APOLLO-OPERATION-NAME: PublishedProductCollections
Accept: multipart/mixed; deferSpec=20220824, application/json
Accept-Encoding: gzip
User-Agent: ...
Market: se
Authorization: Bearer ...
Request body:
{"operationName":"PublishedProductCollections","variables":{},"query":"query PublishedProductCollections { ... }"}
Response headers:
content-type: application/json; charset=utf-8
cf-ray: ...
cf-cache-status: HIT
age: 291
cache-control: public, max-age=180, s-maxage=180
content-encoding: gzip
vary: Origin, Accept-Encoding
x-envoy-upstream-service-time: 75
x-graphql-cache: hit
set-cookie: ...
server: cloudflare
Response body:
(OkHttp) HttpLoggingInterceptor:
{"data":{"publishedProductCollections":[...]}}
(Apollo) LoggingInterceptor:
�????????????|WKn��...
Emil Butiri
08/17/2023, 2:00 PMyschimke
08/17/2023, 2:24 PMyschimke
08/17/2023, 2:25 PMyschimke
08/17/2023, 2:25 PMyschimke
08/17/2023, 2:25 PMyschimke
08/17/2023, 2:26 PMEmil Butiri
08/17/2023, 2:49 PMyschimke
08/17/2023, 2:50 PMEmil Butiri
08/17/2023, 2:54 PM