-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a copy() funtion for the ApolloRequest #3988
Creating a copy() funtion for the ApolloRequest #3988
Conversation
…a new Operation which consumes the exact same values as an existing request and returns the result. Useful for when we want to intercept and relay the ApolloRequest through various stages of the netowrk request.
@AdamMTGreenberg: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
👷 Deploy request for apollo-android-docs pending review.Visit the deploys page to approve it
|
return Builder(operation) | ||
fun newBuilder(): Builder<D> = duplicate(Builder(operation)) | ||
|
||
fun copy(operation: Operation<D>): ApolloRequest<D> = duplicate(Builder(operation)).build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending this ! I understand the use case but I'd like to avoid the "copy" vocabulary here because it hints heavily at data classes which are not really used here.
Instead, maybe use newBuilder(operation: Operation<E>)
? It also makes it more discoverable?
fun newBuilder(): Builder<D> {
return newBuilder(operation)
}
fun <E: Operation.Data> newBuilder(operation: Operation<E>): Builder<E> {
Hi 👋 . I took the liberty of pushing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* Creating a copy() constructor for the ApolloRequest to allow setting a new Operation which consumes the exact same values as an existing request and returns the result. Useful for when we want to intercept and relay the ApolloRequest through various stages of the netowrk request. * add newBuilder(operation) Co-authored-by: Martin Bonnin <[email protected]> (cherry picked from commit c8d3fb7)
Purpose: to allow setting a new
Operation
which consumes the exact same values as an existing request and returns the result. Useful for when we want to intercept and relay theApolloRequest
through various stages of the network request.There are various points in the API where one may want to wrap or proxy calls in the chain and without access to the
Operation
, we cannot. Thiscopy
function would allow the consumer to be sure that all values (beside the UUID) would be copied over, both now and in the future.