Skip to content

Commit

Permalink
add newBuilder(operation)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Apr 5, 2022
1 parent 192f533 commit fe4f41b
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.apollographql.apollo3.api

import com.apollographql.apollo3.annotations.ApolloExperimental
import com.apollographql.apollo3.annotations.ApolloInternal
import com.apollographql.apollo3.api.http.HttpHeader
import com.apollographql.apollo3.api.http.HttpMethod
Expand All @@ -23,12 +24,12 @@ private constructor(
override val canBeBatched: Boolean?,
) : ExecutionOptions {

fun newBuilder(): Builder<D> = duplicate(Builder(operation))
@OptIn(ApolloExperimental::class)
fun newBuilder(): Builder<D> = newBuilder(operation)

fun copy(operation: Operation<D>): ApolloRequest<D> = duplicate(Builder(operation)).build()

private fun duplicate(builder: Builder<D>): Builder<D> {
return builder
@ApolloExperimental
fun <E: Operation.Data> newBuilder(operation: Operation<E>): Builder<E> {
return Builder(operation)
.requestUuid(requestUuid)
.executionContext(executionContext)
.httpMethod(httpMethod)
Expand All @@ -37,6 +38,7 @@ private constructor(
.sendDocument(sendDocument)
.enableAutoPersistedQueries(enableAutoPersistedQueries)
.canBeBatched(canBeBatched)

}

class Builder<D : Operation.Data>(
Expand Down

0 comments on commit fe4f41b

Please sign in to comment.