Repository: apollographql/apollo-kotlin
Pull request #5426 (2023-12-04 13:30:30)

[api] remove some of the ApolloResponse.Builders
Right now we have:

1 `Builder(operation, uuid, data)`
2 `Builder(operation, uuid, exception)`
3 `Builder(operation, uuid, data, errors, extensions, exception)`

1 & 2 are somewhat misleading because they could imply that `data` & `exception` are exclusive which is not the case. 

3. is redundant with calling the different methods of the Builder.

Replace all 3 builders with:

* `Builder(operation, uuid)`

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *apollo-android-docs* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 5f0b4519c3af77753580f3623acef02092322602 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/apollo-android-docs/deploys/656dd4793ff3c60008f48f3d |

Patch:
diff --git a/libraries/apollo-api/api/apollo-api.api b/libraries/apollo-api/api/apollo-api.api
index 5b24e59058..a63b1c4646 100644
--- a/libraries/apollo-api/api/apollo-api.api
+++ b/libraries/apollo-api/api/apollo-api.api
@@ -106,9 +106,8 @@ public final class com/apollographql/apollo3/api/ApolloResponse {
 }
 
 public final class com/apollographql/apollo3/api/ApolloResponse$Builder {
+	public fun <init> (Lcom/apollographql/apollo3/api/Operation;Ljava/util/UUID;)V
 	public fun <init> (Lcom/apollographql/apollo3/api/Operation;Ljava/util/UUID;Lcom/apollographql/apollo3/api/Operation$Data;)V
-	public fun <init> (Lcom/apollographql/apollo3/api/Operation;Ljava/util/UUID;Lcom/apollographql/apollo3/api/Operation$Data;Ljava/util/List;Ljava/util/Map;)V
-	public fun <init> (Lcom/apollographql/apollo3/api/Operation;Ljava/util/UUID;Lcom/apollographql/apollo3/exception/ApolloException;)V
 	public final fun addExecutionContext (Lcom/apollographql/apollo3/api/ExecutionContext;)Lcom/apollographql/apollo3/api/ApolloResponse$Builder;
 	public final fun build ()Lcom/apollographql/apollo3/api/ApolloResponse;
 	public final fun data (Lcom/apollographql/apollo3/api/Operation$Data;)Lcom/apollographql/apollo3/api/ApolloResponse$Builder;
diff --git a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Adapters.kt b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Adapters.kt
index cd42ca5f16..31e7dca503 100644
--- a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Adapters.kt
+++ b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Adapters.kt
@@ -463,7 +463,6 @@ fun <T> Adapter<T>.catchToNull(): Adapter<T?> = CatchToNullAdapter(this)
  *
  * **Note**: [Adapter]s are called from multiple threads and implementations must be thread safe.
  */
-@Deprecated("Used for backward compatibility with 2.x, use Adapter instead", level = DeprecationLevel.ERROR)
+@Deprecated("CustomTypeAdapter was used for backward compatibility with 2.x. Use Adapter instead", level = DeprecationLevel.ERROR)
 @ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v3_0_0)
-interface CustomTypeAdapter<T> {
-}
\ No newline at end of file
+interface CustomTypeAdapter<T>
\ No newline at end of file
diff --git a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/ApolloResponse.kt b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/ApolloResponse.kt
index 0bbaacc4af..fafb8c6d59 100644
--- a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/ApolloResponse.kt
+++ b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/ApolloResponse.kt
@@ -1,5 +1,6 @@
 package com.apollographql.apollo3.api
 
+import com.apollographql.apollo3.annotations.ApolloDeprecatedSince
 import com.apollographql.apollo3.exception.ApolloException
 import com.apollographql.apollo3.exception.ApolloGraphQLException
 import com.apollographql.apollo3.exception.DefaultApolloException
@@ -137,36 +138,23 @@ private constructor(
     private var isLast = false
 
     /**
-     * Constructs a successful response with a valid data, no errors nor extensions
-     */
-    constructor(
-        operation: Operation<D>,
-        requestUuid: Uuid,
-        data: D,
-    ): this(operation, requestUuid, data, null, null, null)
-
-    /**
-     * Constructs a response from data, errors and extensions
+     * Construct a new [Builder] that doesn't contain data, errors nor exception
      *
-     * If there are GraphQL errors, they will also be forwarded to [exception] so that the caller can do all the
-     * checking in a single place
+     * While possible, this case is probably symptomatic of a buggy GraphQL implementation
+     * that returned no data while not setting any error
      */
     constructor(
         operation: Operation<D>,
         requestUuid: Uuid,
-        data: D?,
-        errors: List<Error>?,
-        extensions: Map<String, Any?>?,
-    ): this(operation, requestUuid, data, errors, extensions, null)
+    ): this(operation, requestUuid, null, null, null, null)
 
-    /**
-     * Constructs an exception response
-     */
+    @Deprecated("Use 2 params constructor instead", ReplaceWith("Builder(operation = operation, requestUuid = requestUuid).data(data = data)"))
+    @ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0)
     constructor(
         operation: Operation<D>,
         requestUuid: Uuid,
-        exception: ApolloException
-    ): this(operation, requestUuid, null, null, null, exception)
+        data: D?
+    ): this(operation, requestUuid, data, null, null, null)
 
     fun addExecutionContext(executionContext: ExecutionContext) = apply {
       this.executionContext = this.executionContext + executionContext
diff --git a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Error.kt b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Error.kt
index 05b745ec8e..4b1916c3c2 100644
--- a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Error.kt
+++ b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Error.kt
@@ -7,7 +7,7 @@ import com.apollographql.apollo3.annotations.ApolloDeprecatedSince
  * See https://spec.graphql.org/draft/#sec-Errors.Error-result-format
  */
 class Error
-@Deprecated("Use Error.Builder instead")
+@Deprecated("Use Error.Builder instead", ReplaceWith("Builder(message = message).locations(locations).path(path).extensions(extensions)"))
 @ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0)
 constructor(
     /**
diff --git a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Operations.kt b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Operations.kt
index 70e13545df..10806f03ee 100644
--- a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Operations.kt
+++ b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/Operations.kt
@@ -120,7 +120,8 @@ fun <D : Operation.Data> Operation<D>.parseResponse(
           cause = throwable
       )
     }
-    return ApolloResponse.Builder(requestUuid = requestUuid ?: uuid4(), operation = this, exception = apolloException)
+    return ApolloResponse.Builder(requestUuid = requestUuid ?: uuid4(), operation = this)
+        .exception(exception = apolloException)
         .isLast(true)
         .build()
   }
diff --git a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/internal/ResponseParser.kt b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/internal/ResponseParser.kt
index 1b6a7c1688..02cfa7cef8 100644
--- a/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/internal/ResponseParser.kt
+++ b/libraries/apollo-api/src/commonMain/kotlin/com/apollographql/apollo3/api/internal/ResponseParser.kt
@@ -44,7 +44,11 @@ internal object ResponseParser {
 
     jsonReader.endObject()
 
-    return ApolloResponse.Builder(requestUuid = requestUuid ?: uuid4(), operation = operation, data = data, errors = errors, extensions = extensions).build()
+    return ApolloResponse.Builder(operation = operation, requestUuid = requestUuid ?: uuid4())
+        .errors(errors)
+        .data(data)
+        .extensions(extensions)
+        .build()
   }
 
   fun parseError(
diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/file/OperationBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/file/OperationBuilder.kt
index 6e8fafc67d..a926922548 100644
--- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/file/OperationBuilder.kt
+++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/file/OperationBuilder.kt
@@ -125,7 +125,7 @@ internal class OperationBuilder(
                 The un-minimized version is:
 
 
-                """.trimIndent() + operation.sourceWithFragments.escapeKdoc()
+                """.trimIndent() + operation.sourceWithFragments.asJavadocCodeBlock()
               )
               .build()
           )
@@ -239,11 +239,11 @@ internal class OperationBuilder(
       .addStatement("return $OPERATION_NAME")
       .build()
 
-  /**
-   * Things like `[${'$'}oo]` do not compile. See https://youtrack.jetbrains.com/issue/KT-43906
-   */
-  private fun String.escapeKdoc(): String {
-    return replace("[", "\\[").replace("]", "\\]")
+  private fun String.asJavadocCodeBlock(): String {
+    /**
+     * TODO: proper Javadoc formatting
+     */
+    return this
   }
 
   private fun rootFieldMethodSpec(): MethodSpec {
diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/OperationBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/OperationBuilder.kt
index 91f7b4cee8..5ea4558a5a 100644
--- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/OperationBuilder.kt
+++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/OperationBuilder.kt
@@ -183,7 +183,7 @@ internal class OperationBuilder(
                 The un-minimized version is:
 
 
-                """.trimIndent() + operation.sourceWithFragments.escapeKdoc()
+                """.trimIndent() + operation.sourceWithFragments.asKotlinCodeBlock()
               )
               .build()
           )
@@ -214,7 +214,7 @@ internal class OperationBuilder(
    *
    * See https://youtrack.jetbrains.com/issue/KT-43906
    */
-  private fun String.escapeKdoc(): String {
+  private fun String.asKotlinCodeBlock(): String {
     return "```\n$this\n```\n"
   }
 
diff --git a/libraries/apollo-compose-support-incubating/src/main/java/com/apollographql/apollo3/compose/State.kt b/libraries/apollo-compose-support-incubating/src/main/java/com/apollographql/apollo3/compose/State.kt
index 3865af0988..777828bb24 100644
--- a/libraries/apollo-compose-support-incubating/src/main/java/com/apollographql/apollo3/compose/State.kt
+++ b/libraries/apollo-compose-support-incubating/src/main/java/com/apollographql/apollo3/compose/State.kt
@@ -37,7 +37,7 @@ import kotlin.coroutines.EmptyCoroutineContext
 fun <D : Operation.Data> ApolloCall<D>.toState(context: CoroutineContext = EmptyCoroutineContext): State<ApolloResponse<D>?> {
   val responseFlow = remember {
     toFlow()
-        .catch { emit(ApolloResponse.Builder(operation, uuid4(), it as? ApolloException ?: throw it).build()) }
+        .catch { emit(ApolloResponse.Builder(operation, uuid4()).exception(it as? ApolloException ?: throw it).build()) }
   }
   return responseFlow.collectAsState(initial = null, context = context)
 }
@@ -62,7 +62,7 @@ fun <D : Operation.Data> ApolloCall<D>.toState(context: CoroutineContext = Empty
 fun <D : Query.Data> ApolloCall<D>.watchAsState(context: CoroutineContext = EmptyCoroutineContext): State<ApolloResponse<D>?> {
   val responseFlow = remember {
     watch()
-        .catch { emit(ApolloResponse.Builder(operation, uuid4(), it as? ApolloException ?: throw it).build()) }
+        .catch { emit(ApolloResponse.Builder(operation, uuid4()).exception(it as? ApolloException ?: throw it).build()) }
   }
   return responseFlow.collectAsState(initial = null, context = context)
 }
diff --git a/libraries/apollo-mockserver/api/apollo-mockserver.api b/libraries/apollo-mockserver/api/apollo-mockserver.api
index 22d45eaec8..dbc588bc29 100644
--- a/libraries/apollo-mockserver/api/apollo-mockserver.api
+++ b/libraries/apollo-mockserver/api/apollo-mockserver.api
@@ -70,9 +70,7 @@ public abstract interface class com/apollographql/apollo3/mockserver/MockServerH
 
 public final class com/apollographql/apollo3/mockserver/MockServerKt {
 	public static final fun MockServer ()Lcom/apollographql/apollo3/mockserver/MockServer;
-	public static final fun MockServer (I)Lcom/apollographql/apollo3/mockserver/MockServer;
 	public static final fun MockServer (Lcom/apollographql/apollo3/mockserver/MockServerHandler;)Lcom/apollographql/apollo3/mockserver/MockServer;
-	public static synthetic fun MockServer$default (IILjava/lang/Object;)Lcom/apollographql/apollo3/mockserver/MockServer;
 	public static final fun awaitRequest-8Mi8wO0 (Lcom/apollographql/apollo3/mockserver/MockServer;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
 	public static synthetic fun awaitRequest-8Mi8wO0$default (Lcom/apollographql/apollo3/mockserver/MockServer;JLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
 	public static final fun enqueue (Lcom/apollographql/apollo3/mockserver/MockServer;Ljava/lang/String;JI)V
diff --git a/libraries/apollo-mockserver/src/commonMain/kotlin/com/apollographql/apollo3/mockserver/MockServer.kt b/libraries/apollo-mockserver/src/commonMain/kotlin/com/apollographql/apollo3/mockserver/MockServer.kt
index 8005469124..e8d759eb08 100644
--- a/libraries/apollo-mockserver/src/commonMain/kotlin/com/apollographql/apollo3/mockserver/MockServer.kt
+++ b/libraries/apollo-mockserver/src/commonMain/kotlin/com/apollographql/apollo3/mockserver/MockServer.kt
@@ -16,7 +16,6 @@ import okio.ByteString
 import okio.ByteString.Companion.encodeUtf8
 import okio.Closeable
 import kotlin.js.JsName
-import kotlin.jvm.JvmOverloads
 import kotlin.time.Duration
 import kotlin.time.Duration.Companion.seconds
 
@@ -249,11 +248,10 @@ internal class MockServerImpl(
 }
 
 @JsName("createMockServer")
-@JvmOverloads
-fun MockServer(port: Int = 0): MockServer = MockServerImpl(
+fun MockServer(): MockServer = MockServerImpl(
     QueueMockServerHandler(),
     true,
-    TcpServer(port),
+    TcpServer(0),
     null)
 
 @Deprecated("Use MockServer.Builder() instead", level = DeprecationLevel.ERROR)
diff --git a/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt b/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
index 590aefbc68..f94ba23994 100644
--- a/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
+++ b/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
@@ -179,7 +179,8 @@ internal object FetchPolicyRouterInterceptor : ApolloInterceptor {
         }
 
         emit(
-            ApolloResponse.Builder(request.operation, request.requestUuid, exception)
+            ApolloResponse.Builder(request.operation, request.requestUuid)
+                .exception(exception)
                 .build()
 
         )
diff --git a/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt b/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
index c71135985c..deec0d5ef5 100644
--- a/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
+++ b/libraries/apollo-normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
@@ -215,8 +215,8 @@ internal class ApolloCacheInterceptor(
       return ApolloResponse.Builder(
           requestUuid = request.requestUuid,
           operation = operation,
-          exception = e,
       )
+          .exception(e)
           .addExecutionContext(request.executionContext)
           .cacheInfo(
               CacheInfo.Builder()
@@ -233,10 +233,9 @@ internal class ApolloCacheInterceptor(
     return ApolloResponse.Builder(
         requestUuid = request.requestUuid,
         operation = operation,
-        data = data,
-        errors = null,
-        extensions = null
-    ).addExecutionContext(request.executionContext)
+    )
+        .data(data)
+        .addExecutionContext(request.executionContext)
         .cacheInfo(
             CacheInfo.Builder()
                 .cacheStartMillis(startMillis)
diff --git a/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt b/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
index 590aefbc68..f94ba23994 100644
--- a/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
+++ b/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/FetchPolicyInterceptors.kt
@@ -179,7 +179,8 @@ internal object FetchPolicyRouterInterceptor : ApolloInterceptor {
         }
 
         emit(
-            ApolloResponse.Builder(request.operation, request.requestUuid, exception)
+            ApolloResponse.Builder(request.operation, request.requestUuid)
+                .exception(exception)
                 .build()
 
         )
diff --git a/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt b/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
index ff6fd5aff6..b7e11648f8 100644
--- a/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
+++ b/libraries/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo3/cache/normalized/internal/ApolloCacheInterceptor.kt
@@ -215,8 +215,8 @@ internal class ApolloCacheInterceptor(
       return ApolloResponse.Builder(
           requestUuid = request.requestUuid,
           operation = operation,
-          exception = e,
       )
+          .exception(e)
           .addExecutionContext(request.executionContext)
           .cacheInfo(
               CacheInfo.Builder()
@@ -233,10 +233,8 @@ internal class ApolloCacheInterceptor(
     return ApolloResponse.Builder(
         requestUuid = request.requestUuid,
         operation = operation,
-        data = data,
-        errors = null,
-        extensions = null,
-    ).addExecutionContext(request.executionContext)
+    ).data(data)
+        .addExecutionContext(request.executionContext)
         .cacheInfo(
             CacheInfo.Builder()
                 .cacheStartMillis(startMillis)
diff --git a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/interceptor/internal/AutoPersistedQueryInterceptor.java b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/interceptor/internal/AutoPersistedQueryInterceptor.java
index fb9f3138ab..f2fd02d01c 100644
--- a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/interceptor/internal/AutoPersistedQueryInterceptor.java
+++ b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/interceptor/internal/AutoPersistedQueryInterceptor.java
@@ -50,7 +50,8 @@ public class AutoPersistedQueryInterceptor implements ApolloInterceptor {
         if (isPersistedQueryNotFound(response.errors)) {
           continueWithDocumentRequest(chain, request, callback);
         } else if (isPersistedQueryNotSupported(response.errors)) {
-          callback.onResponse(new ApolloResponse.Builder<>(request.getOperation(), request.getRequestUuid(), new AutoPersistedQueriesNotSupported())
+          callback.onResponse(new ApolloResponse.Builder<>(request.getOperation(), request.getRequestUuid())
+              .exception(new AutoPersistedQueriesNotSupported())
               .build());
         } else {
           // Cache hit
diff --git a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/http/HttpNetworkTransport.java b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/http/HttpNetworkTransport.java
index f646acaeb7..2c55797cbc 100644
--- a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/http/HttpNetworkTransport.java
+++ b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/http/HttpNetworkTransport.java
@@ -75,7 +75,8 @@ public class HttpNetworkTransport implements NetworkTransport {
   }
 
   @NotNull private static <D extends Operation.Data> ApolloResponse<D> getExceptionResponse(@NotNull ApolloRequest<D> request, @NotNull ApolloException exception) {
-    return new ApolloResponse.Builder<>(request.getOperation(), request.getRequestUuid(), exception)
+    return new ApolloResponse.Builder<>(request.getOperation(), request.getRequestUuid())
+        .exception(exception)
         .build();
   }
 
diff --git a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/ws/WebSocketNetworkTransport.java b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/ws/WebSocketNetworkTransport.java
index b09528b23f..855fc5cd77 100644
--- a/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/ws/WebSocketNetworkTransport.java
+++ b/libraries/apollo-runtime-java/src/main/java/com/apollographql/apollo3/runtime/java/network/ws/WebSocketNetworkTransport.java
@@ -151,7 +151,8 @@ public class WebSocketNetworkTransport implements NetworkTransport {
       if (subscriptionInfo == null) return;
       ApolloRequest<?> request = subscriptionInfo.request;
       //noinspection unchecked,rawtypes
-      subscriptionInfo.callback.onResponse(new ApolloResponse.Builder(request.getOperation(), request.getRequestUuid(), new SubscriptionOperationException(request.getOperation().name(), payload))
+      subscriptionInfo.callback.onResponse(new ApolloResponse.Builder(request.getOperation(), request.getRequestUuid())
+          .exception(new SubscriptionOperationException(request.getOperation().name(), payload))
           .build());
       disposeSubscription(id);
     }
@@ -190,7 +191,8 @@ public class WebSocketNetworkTransport implements NetworkTransport {
         activeSubscriptions.clear();
         for (SubscriptionInfo subscriptionInfo : activeSubscriptionList) {
           //noinspection unchecked,rawtypes
-          subscriptionInfo.callback.onResponse(new ApolloResponse.Builder(subscriptionInfo.request.getOperation(), subscriptionInfo.request.getRequestUuid(), networkException)
+          subscriptionInfo.callback.onResponse(new ApolloResponse.Builder(subscriptionInfo.request.getOperation(), subscriptionInfo.request.getRequestUuid())
+              .exception(networkException)
               .build());
           subscriptionInfo.disposable.dispose();
         }
diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/interceptor/AutoPersistedQueryInterceptor.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/interceptor/AutoPersistedQueryInterceptor.kt
index fb1cb18774..571f48ca97 100644
--- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/interceptor/AutoPersistedQueryInterceptor.kt
+++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/interceptor/AutoPersistedQueryInterceptor.kt
@@ -51,7 +51,8 @@ class AutoPersistedQueryInterceptor(
         }
         isPersistedQueryNotSupported(response.errors) -> {
           emit(
-              ApolloResponse.Builder(request.operation, request.requestUuid, AutoPersistedQueriesNotSupported())
+              ApolloResponse.Builder(request.operation, request.requestUuid)
+                  .exception(AutoPersistedQueriesNotSupported())
                   .build()
           )
           return@flow
diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/HttpNetworkTransport.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/HttpNetworkTransport.kt
index 0aa90046b3..3d8de4ab6e 100644
--- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/HttpNetworkTransport.kt
+++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/http/HttpNetworkTransport.kt
@@ -108,7 +108,8 @@ private constructor(
           cause = throwable
       )
     }
-    return ApolloResponse.Builder(requestUuid = uuid4(), operation = operation, exception = apolloException)
+    return ApolloResponse.Builder(requestUuid = uuid4(), operation = operation,)
+        .exception(apolloException)
         .isLast(true)
         .build()
   }
diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/ws/WebSocketNetworkTransport.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/ws/WebSocketNetworkTransport.kt
index ea503e70fb..5def6c8cb6 100644
--- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/ws/WebSocketNetworkTransport.kt
+++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/network/ws/WebSocketNetworkTransport.kt
@@ -340,7 +340,8 @@ private constructor(
   private fun <D : Operation.Data> errorResponse(
       request: ApolloRequest<D>,
       apolloException: ApolloException,
-  ) = ApolloResponse.Builder(requestUuid = request.requestUuid, operation = request.operation, exception = apolloException)
+  ) = ApolloResponse.Builder(requestUuid = request.requestUuid, operation = request.operation)
+      .exception(apolloException)
       .isLast(true)
       .build()
 


Test patch:
diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/TestQuery.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/TestQuery.java.expected
index 6caef17d85..453de3d132 100644
--- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/TestQuery.java.expected
+++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/TestQuery.java.expected
@@ -31,8 +31,8 @@ public class TestQuery implements Mutation<TestQuery.Data> {
    * mutation TestQuery($ep: Episode!) {
    *   createReview(episode: $ep, review: {
    *     stars: 5
-   *     listOfEnums: \[JEDI,EMPIRE,NEWHOPE\]
-   *     listOfStringNonOptional: \["1","2","3"\]
+   *     listOfEnums: [JEDI,EMPIRE,NEWHOPE]
+   *     listOfStringNonOptional: ["1","2","3"]
    *     favoriteColor: {
    *       red: 1
    *       blue: 1
diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/TestQuery.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/TestQuery.java.expected
index a92d2e9267..838f2972c5 100644
--- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/TestQuery.java.expected
+++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/TestQuery.java.expected
@@ -40,9 +40,9 @@ public class TestQuery implements Query<TestQuery.Data> {
    *     }
    *
    *     booleanNonOptional: false
-   *     listOfStringNonOptional: \[\]
+   *     listOfStringNonOptional: []
    *   }
-   *   , listOfInts: \[$stars,$stars\]) {
+   *   , listOfInts: [$stars,$stars]) {
    *     name
    *     height(unit: FOOT)
    *   }
diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/TestQuery.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/TestQuery.java.expected
index 1db3f59b0e..ce9e0e1036 100644
--- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/TestQuery.java.expected
+++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/TestQuery.java.expected
@@ -40,9 +40,9 @@ public class TestQuery implements Query<TestQuery.Data> {
    *     }
    *
    *     booleanNonOptional: false
-   *     listOfStringNonOptional: \[\]
+   *     listOfStringNonOptional: []
    *   }
-   *   , listOfInts: \[$stars,$stars\]) {
+   *   , listOfInts: [$stars,$stars]) {
    *     name
    *     height(unit: FOOT)
    *   }
diff --git a/libraries/apollo-testing-support/src/commonMain/kotlin/com/apollographql/apollo3/testing/TestNetworkTransport.kt b/libraries/apollo-testing-support/src/commonMain/kotlin/com/apollographql/apollo3/testing/TestNetworkTransport.kt
index 0055b8e2c5..b2306a7c2c 100644
--- a/libraries/apollo-testing-support/src/commonMain/kotlin/com/apollographql/apollo3/testing/TestNetworkTransport.kt
+++ b/libraries/apollo-testing-support/src/commonMain/kotlin/com/apollographql/apollo3/testing/TestNetworkTransport.kt
@@ -34,7 +34,9 @@ class QueueTestNetworkTransport : NetworkTransport {
 
       val apolloResponse = when (response) {
         is TestResponse.NetworkError -> {
-          ApolloResponse.Builder(operation = request.operation, requestUuid = request.requestUuid, exception = ApolloNetworkException("Network error queued in QueueTestNetworkTransport")).build()
+          ApolloResponse.Builder(operation = request.operation, requestUuid = request.requestUuid)
+              .exception(exception = ApolloNetworkException("Network error queued in QueueTestNetworkTransport"))
+              .build()
         }
 
         is TestResponse.Response -> {
@@ -77,7 +79,9 @@ class MapTestNetworkTransport : NetworkTransport {
 
       val apolloResponse = when (response) {
         is TestResponse.NetworkError -> {
-          ApolloResponse.Builder(operation = request.operation, requestUuid = request.requestUuid, exception = ApolloNetworkException("Network error registered in MapTestNetworkTransport")).build()
+          ApolloResponse.Builder(operation = request.operation, requestUuid = request.requestUuid)
+              .exception(exception = ApolloNetworkException("Network error registered in MapTestNetworkTransport"))
+              .build()
         }
 
         is TestResponse.Response -> {
@@ -119,10 +123,9 @@ fun <D : Operation.Data> ApolloClient.enqueueTestResponse(
     ApolloResponse.Builder(
         operation = operation,
         requestUuid = uuid4(),
-        data = data,
-        errors = errors,
-        extensions = null
     )
+        .data(data)
+        .errors(errors)
         .build()
 )
 
@@ -149,10 +152,9 @@ fun <D : Operation.Data> ApolloClient.registerTestResponse(
     ApolloResponse.Builder(
         operation = operation,
         requestUuid = uuid4(),
-        data = data,
-        errors = errors,
-        extensions = null
     )
+        .data(data)
+        .errors(errors)
         .build()
 )
 
diff --git a/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt b/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt
index e36a49e395..a36eb1a41d 100644
--- a/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt
+++ b/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt
@@ -299,28 +299,28 @@ class DeferNormalizedCacheTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null))
-            )
-        ).build(),
+        ).data(WithFragmentSpreadsQuery.Data(
+            listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null))
+        )).build(),
 
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
-                    ComputerFields.Screen("Screen", "640x480", null))))
-            )
-        ).build(),
+        ).data(WithFragmentSpreadsQuery.Data(
+            listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
+                ComputerFields.Screen("Screen", "640x480", null))))
+        )).build(),
 
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
-                    ComputerFields.Screen("Screen", "640x480", null))))
-            )
         )
+            .data(
+                WithFragmentSpreadsQuery.Data(
+                    listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
+                        ComputerFields.Screen("Screen", "640x480", null))))
+                )
+            )
             .errors(
                 listOf(
                     Error.Builder(message = "Cannot resolve isColor")
@@ -350,19 +350,17 @@ class DeferNormalizedCacheTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null))
-            )
-        ).build(),
+        ).data(WithFragmentSpreadsQuery.Data(
+            listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null))
+        )).build(),
 
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
-                    ComputerFields.Screen("Screen", "640x480", null))))
-            )
-        ).build(),
+        ).data(WithFragmentSpreadsQuery.Data(
+            listOf(WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
+                ComputerFields.Screen("Screen", "640x480", null))))
+        )).build(),
     )
 
     apolloClient = ApolloClient.Builder()
@@ -378,7 +376,8 @@ class DeferNormalizedCacheTest {
                     emit(networkResponse as ApolloResponse<D>)
                   }
                   delay(10)
-                  emit(ApolloResponse.Builder(requestUuid = uuid, operation = query, exception = ApolloNetworkException("Network error"))
+                  emit(ApolloResponse.Builder(requestUuid = uuid, operation = query)
+                      .exception(ApolloNetworkException("Network error"))
                       .isLast(true)
                       .build() as ApolloResponse<D>)
                 }
diff --git a/tests/defer/src/commonTest/kotlin/test/DeferTest.kt b/tests/defer/src/commonTest/kotlin/test/DeferTest.kt
index 1f43496dd0..ecd1cc2516 100644
--- a/tests/defer/src/commonTest/kotlin/test/DeferTest.kt
+++ b/tests/defer/src/commonTest/kotlin/test/DeferTest.kt
@@ -173,18 +173,18 @@ class DeferTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(
-                    WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null),
-                    WithFragmentSpreadsQuery.Computer("Computer", "Computer2", null),
-                )
+        ).data(WithFragmentSpreadsQuery.Data(
+            listOf(
+                WithFragmentSpreadsQuery.Computer("Computer", "Computer1", null),
+                WithFragmentSpreadsQuery.Computer("Computer", "Computer2", null),
             )
-        ).build(),
+        )).build(),
 
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
+        ).data(
+            WithFragmentSpreadsQuery.Data(
                 listOf(
                     WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
                         ComputerFields.Screen("Screen", "640x480", null))),
@@ -196,14 +196,16 @@ class DeferTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
-                listOf(
-                    WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
-                        ComputerFields.Screen("Screen", "640x480", null))),
-                    WithFragmentSpreadsQuery.Computer("Computer", "Computer2", null),
+        )
+            .data(
+                WithFragmentSpreadsQuery.Data(
+                    listOf(
+                        WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
+                            ComputerFields.Screen("Screen", "640x480", null))),
+                        WithFragmentSpreadsQuery.Computer("Computer", "Computer2", null),
+                    )
                 )
             )
-        )
             .errors(
                 listOf(
                     Error.Builder(message = "Cannot resolve isColor")
@@ -217,7 +219,8 @@ class DeferTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
+        ).data(
+            WithFragmentSpreadsQuery.Data(
                 listOf(
                     WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
                         ComputerFields.Screen("Screen", "640x480", null))),
@@ -230,7 +233,8 @@ class DeferTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = WithFragmentSpreadsQuery.Data(
+        ).data(
+            WithFragmentSpreadsQuery.Data(
                 listOf(
                     WithFragmentSpreadsQuery.Computer("Computer", "Computer1", ComputerFields("386", 1993,
                         ComputerFields.Screen("Screen", "640x480", null))),
diff --git a/tests/defer/src/commonTest/kotlin/test/DeferWithRouterTest.kt b/tests/defer/src/commonTest/kotlin/test/DeferWithRouterTest.kt
index 969cca209e..0d50525c2d 100644
--- a/tests/defer/src/commonTest/kotlin/test/DeferWithRouterTest.kt
+++ b/tests/defer/src/commonTest/kotlin/test/DeferWithRouterTest.kt
@@ -275,23 +275,27 @@ class DeferWithRouterTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = HandlesErrorsThrownInDeferredFragmentsQuery.Data(
-                HandlesErrorsThrownInDeferredFragmentsQuery.Computer(
-                    "Computer", "Computer1", null
+        )
+            .data(
+                HandlesErrorsThrownInDeferredFragmentsQuery.Data(
+                    HandlesErrorsThrownInDeferredFragmentsQuery.Computer(
+                        "Computer", "Computer1", null
+                    )
                 )
             )
-        )
             .build(),
 
         ApolloResponse.Builder(
             query,
             uuid,
-            data = HandlesErrorsThrownInDeferredFragmentsQuery.Data(
-                HandlesErrorsThrownInDeferredFragmentsQuery.Computer(
-                    "Computer", "Computer1", ComputerErrorField(null)
+        )
+            .data(
+                HandlesErrorsThrownInDeferredFragmentsQuery.Data(
+                    HandlesErrorsThrownInDeferredFragmentsQuery.Computer(
+                        "Computer", "Computer1", ComputerErrorField(null)
+                    )
                 )
             )
-        )
             .errors(
                 listOf(
                     Error.Builder(message = "Subgraph errors redacted")
@@ -319,7 +323,8 @@ class DeferWithRouterTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Data(
+        ).data(
+            HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Data(
                 HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Computer(
                     "Computer", "Computer1", null
                 )
@@ -330,12 +335,14 @@ class DeferWithRouterTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Data(
-                HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Computer(
-                    "Computer", "Computer1", null
+        )
+            .data(
+                HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Data(
+                    HandlesNonNullableErrorsThrownInDeferredFragmentsQuery.Computer(
+                        "Computer", "Computer1", null
+                    )
                 )
             )
-        )
             .errors(listOf(Error.Builder(message = "Subgraph errors redacted").build()))
             .build(),
     )
@@ -355,7 +362,8 @@ class DeferWithRouterTest {
         ApolloResponse.Builder(
             query,
             uuid,
-            data = HandlesNonNullableErrorsThrownOutsideDeferredFragmentsQuery.Data(
+        ).data(
+            HandlesNonNullableErrorsThrownOutsideDeferredFragmentsQuery.Data(
                 null
             )
         )
diff --git a/tests/test-network-transport/src/test/kotlin/testnetworktransport/CustomTestNetworkTransportHandlerTest.kt b/tests/test-network-transport/src/test/kotlin/testnetworktransport/CustomTestNetworkTransportHandlerTest.kt
index 0a1e332bd0..3d5db177fc 100644
--- a/tests/test-network-transport/src/test/kotlin/testnetworktransport/CustomTestNetworkTransportHandlerTest.kt
+++ b/tests/test-network-transport/src/test/kotlin/testnetworktransport/CustomTestNetworkTransportHandlerTest.kt
@@ -41,7 +41,8 @@ class CustomTestNetworkTransportHandlerTest {
           ApolloResponse.Builder(
               operation = GetHeroQuery("mock"),
               requestUuid = request.requestUuid,
-              data = GetHeroQuery.Data {
+          ).data(
+              GetHeroQuery.Data {
                 hero = buildDroid {
                   name = "Droid ${counter++}"
                 }
@@ -67,7 +68,7 @@ class CustomTestNetworkTransportHandlerTest {
   @Test
   fun registerAndQueueMethodsFail() = runTest(before = { setUp() }, after = { tearDown() }) {
     assertFailsWith(IllegalStateException::class) {
-      apolloClient.enqueueTestResponse(ApolloResponse.Builder(GetHeroQuery("id"), uuid4(), DefaultApolloException()).build())
+      apolloClient.enqueueTestResponse(ApolloResponse.Builder(GetHeroQuery("id"), uuid4()).exception( DefaultApolloException()).build())
     }
     assertFailsWith(IllegalStateException::class) {
       apolloClient.registerTestResponse(GetHeroQuery("id"), null)
diff --git a/tests/test-network-transport/src/test/kotlin/testnetworktransport/MapTestNetworkTransportHandlerTest.kt b/tests/test-network-transport/src/test/kotlin/testnetworktransport/MapTestNetworkTransportHandlerTest.kt
index de8f914bdc..f904fad378 100644
--- a/tests/test-network-transport/src/test/kotlin/testnetworktransport/MapTestNetworkTransportHandlerTest.kt
+++ b/tests/test-network-transport/src/test/kotlin/testnetworktransport/MapTestNetworkTransportHandlerTest.kt
@@ -33,16 +33,13 @@ class MapTestNetworkTransportHandlerTest {
     val query1 = GetHeroQuery("001")
     val testResponse1 = ApolloResponse.Builder(
         operation = query1,
-        requestUuid = uuid4(),
-        data = null,
-        errors = listOf(
-            Error.Builder(message = "There was an error")
-                .locations(listOf(Error.Location(line = 1, column = 2)))
-                .path(listOf("hero", "name"))
-                .build()
-        ),
-        extensions = null
-    ).build()
+        requestUuid = uuid4()
+    ).errors(listOf(
+        Error.Builder(message = "There was an error")
+            .locations(listOf(Error.Location(line = 1, column = 2)))
+            .path(listOf("hero", "name"))
+            .build()
+    )).build()
 
     val query2 = GetHeroQuery("002")
     val query2TestData = GetHeroQuery.Data(
@@ -54,10 +51,11 @@ class MapTestNetworkTransportHandlerTest {
             onHuman = null
         )
     )
-    val testResponse2 = ApolloResponse.Builder(query2, uuid4(), query2TestData).build()
+    val testResponse2 = ApolloResponse.Builder(query2, uuid4()).data(query2TestData).build()
 
     val query3 = GetHeroNameOnlyQuery()
-    val testResponse3 = ApolloResponse.Builder(query3, uuid4(), GetHeroNameOnlyQuery.Data(GetHeroNameOnlyQuery.Hero(name = "Darth Vader")))
+    val testResponse3 = ApolloResponse.Builder(query3, uuid4())
+        .data(GetHeroNameOnlyQuery.Data(GetHeroNameOnlyQuery.Hero(name = "Darth Vader")))
         .build()
 
     apolloClient.apply {
diff --git a/tests/test-network-transport/src/test/kotlin/testnetworktransport/QueueTestNetworkTransportHandlerTest.kt b/tests/test-network-transport/src/test/kotlin/testnetworktransport/QueueTestNetworkTransportHandlerTest.kt
index e89c36311e..c795e06ada 100644
--- a/tests/test-network-transport/src/test/kotlin/testnetworktransport/QueueTestNetworkTransportHandlerTest.kt
+++ b/tests/test-network-transport/src/test/kotlin/testnetworktransport/QueueTestNetworkTransportHandlerTest.kt
@@ -36,14 +36,13 @@ class QueueTestNetworkTransportHandlerTest {
     val testResponse1 = ApolloResponse.Builder(
         operation = query1,
         requestUuid = uuid4(),
-        data = null,
-        errors = listOf(
+    ).errors(
+        listOf(
             Error.Builder(message = "There was an error")
                 .locations(listOf(Error.Location(line = 1, column = 2)))
                 .path(listOf("hero", "name"))
                 .build()
-        ),
-        extensions = null
+        )
     ).build()
 
     val query2 = GetHeroQuery("002")
@@ -56,10 +55,11 @@ class QueueTestNetworkTransportHandlerTest {
             onHuman = null
         )
     )
-    val testResponse2 = ApolloResponse.Builder(query2, uuid4(), query2TestData).build()
+    val testResponse2 = ApolloResponse.Builder(query2, uuid4()).data(query2TestData).build()
 
     val query3 = GetHeroNameOnlyQuery()
-    val testResponse3 = ApolloResponse.Builder(query3, uuid4(), GetHeroNameOnlyQuery.Data(GetHeroNameOnlyQuery.Hero(name = "Darth Vader")))
+    val testResponse3 = ApolloResponse.Builder(query3, uuid4())
+        .data(GetHeroNameOnlyQuery.Data(GetHeroNameOnlyQuery.Hero(name = "Darth Vader")))
         .build()
 
     apolloClient.apply {