From 9185be6b0e14ab7435266b5db8b00c5bef278de8 Mon Sep 17 00:00:00 2001 From: Jan Duzinkiewicz Date: Tue, 11 Jun 2024 17:01:13 -0700 Subject: [PATCH] making not correctly ending json responses throw an exception instead of logging a warning, as per PR feedback --- .../apollo3/network/http/BatchingHttpInterceptor.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/BatchingHttpInterceptor.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/BatchingHttpInterceptor.kt index d519271e79e..17408b35c1f 100644 --- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/BatchingHttpInterceptor.kt +++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/BatchingHttpInterceptor.kt @@ -19,6 +19,7 @@ import com.apollographql.apollo3.api.json.writeArray import com.apollographql.apollo3.exception.ApolloException import com.apollographql.apollo3.exception.ApolloHttpException import com.apollographql.apollo3.exception.DefaultApolloException +import com.apollographql.apollo3.exception.JsonDataException import com.apollographql.apollo3.internal.CloseableSingleThreadDispatcher import com.apollographql.apollo3.mpp.currentTimeMillis import kotlinx.coroutines.CompletableDeferred @@ -186,7 +187,7 @@ class BatchingHttpInterceptor @JvmOverloads constructor( // TODO: this is most likely going to transform BigNumbers into strings, not sure how much of an issue that is AnyAdapter.fromJson(jsonReader, CustomScalarAdapters.Empty).also { if (jsonReader.peek() != JsonReader.Token.END_DOCUMENT) { - println("Apollo: extra tokens after payload") + throw JsonDataException("Expected END_DOCUMENT but was ${jsonReader.peek()}") } } }