@@ -7,6 +7,7 @@ import com.apollographql.apollo.api.CustomScalarAdapters
7
7
import com.apollographql.apollo.api.ExecutionOptions
8
8
import com.apollographql.apollo.api.Operation
9
9
import com.apollographql.apollo.api.http.HttpBody
10
+ import com.apollographql.apollo.api.http.HttpHeader
10
11
import com.apollographql.apollo.api.http.HttpMethod
11
12
import com.apollographql.apollo.api.http.HttpRequest
12
13
import com.apollographql.apollo.api.http.HttpResponse
@@ -176,6 +177,7 @@ class BatchingHttpInterceptor @JvmOverloads constructor(
176
177
.build()
177
178
178
179
var exception: ApolloException ? = null
180
+ var responseHeader = emptyList<HttpHeader >()
179
181
val result = try {
180
182
val response = interceptorChain!! .proceed(request)
181
183
if (response.statusCode !in 200 .. 299 ) {
@@ -193,6 +195,7 @@ class BatchingHttpInterceptor @JvmOverloads constructor(
193
195
)
194
196
}
195
197
val responseBody = response.body ? : throw DefaultApolloException (" null body when executing batched query" )
198
+ responseHeader = response.headers
196
199
197
200
val list = BufferedSourceJsonReader (responseBody).use { jsonReader ->
198
201
// TODO: this is most likely going to transform BigNumbers into strings, not sure how much of an issue that is
@@ -235,6 +238,11 @@ class BatchingHttpInterceptor @JvmOverloads constructor(
235
238
pending[index].deferred.complete(
236
239
HttpResponse .Builder (statusCode = 200 )
237
240
.body(Buffer ().write(byteString))
241
+ /*
242
+ * Return the global batch headers to individual responses.
243
+ * This is useful for things like cache-control that rely on HTTP headers.
244
+ */
245
+ .headers(responseHeader)
238
246
.build()
239
247
)
240
248
}
0 commit comments