Skip to content
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

Cleanup ApolloClient.Builder #5683

Merged
merged 1 commit into from
Mar 6, 2024
Merged

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Mar 5, 2024

Prep work for adding more retry related things in ApolloClient.Builder.

This PR:

  • moves the networkTransport/subscriptionNetworkTransport creation and checks to ApolloClient.
  • makes all Builder functions accept a nullable value to reset the parameter (and consistency as well).
  • gives ApolloClient its own copy of Builder (never mutated)

The previous code was problematic in cases like this:

val builder = ApolloClient.Builder().serverUrl("https://example.com")

val apolloClient = builder.build()
builder.serverUrl("https://somethingelse.com")

// customize cache here
val cachingApolloClient = apolloClient1.newBuilder().normalizedCache(...).build()
// Oh no, cachingApolloClient use somethingelse.com instead of example.com

See also #3759

@martinbonnin martinbonnin requested a review from BoD as a code owner March 5, 2024 11:15
Copy link

netlify bot commented Mar 5, 2024

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit 13c3518
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/65e759f79e9cbf0008d6723f

Comment on lines -97 to +111
public final fun httpExposeErrorBody (Z)Lcom/apollographql/apollo3/ApolloClient$Builder;
public final fun httpExposeErrorBody (Ljava/lang/Boolean;)Lcom/apollographql/apollo3/ApolloClient$Builder;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking ABI change because the parameter is now nullable.

public synthetic fun <init> (Lcom/apollographql/apollo3/network/NetworkTransport;Lcom/apollographql/apollo3/api/CustomScalarAdapters;Lcom/apollographql/apollo3/network/NetworkTransport;Ljava/util/List;Lcom/apollographql/apollo3/api/ExecutionContext;Lkotlinx/coroutines/CoroutineDispatcher;Lcom/apollographql/apollo3/api/http/HttpMethod;Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lcom/apollographql/apollo3/ApolloClient$Builder;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/apollographql/apollo3/ApolloClient$Builder;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implementation detail => not breaking

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚙️

@martinbonnin martinbonnin merged commit 64ae499 into main Mar 6, 2024
9 checks passed
@martinbonnin martinbonnin deleted the apollo-client-new-builder branch March 6, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants