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

Deprecate all intermediate Builder functions #6287

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Nov 27, 2024

Deprecate things like

ApolloClient.Builder()
    .httpEngine(...)
    .webSocketTimeoutMillis(...)
    // etc...
    .build()

Those are properties of HttpNetworkTransport and WebSocketNetworkTransport respectively and what we gain in the "simple" cases is outweight by the complexity induced (more docs, impossible states, bad error messages (#6253), etc...).

I am now convinced that precedence rules are clumsy, and this PR removes a lot of the precedence.

The code above can be replaced by the (longer but also much more consistent and less footgunny) version:

ApolloClient.Builder()
    .networkTransport(HttpNetworkTransport.Builder().httpEngine(engine).build())
    .subscriptionNetworkTransport(WebSocketNetworkTransport.Builder().timeoutMillis(timeoutMillis).build())
    // etc...
    .build()

I just kept serverUrl() because it's used everywhere in the docs.

@martinbonnin martinbonnin requested a review from BoD as a code owner November 27, 2024 17:38
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 27, 2024

✅ Docs Preview Ready

No new or changed pages found.

@martinbonnin martinbonnin changed the base branch from apollo-interceptor-closeable to remove-closeable-dispatcher November 27, 2024 17:39
Comment on lines 19 to 22
actual class DefaultWebSocketEngine(
private val webSocketFactory: WebSocket.Factory,
webSocketFactory: () -> WebSocket.Factory,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New constructor. We need that to avoid initializing from the main thread

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.

More explicit > less explicit 👍

"com.apollographql.apollo.network.ws.WebSocketNetworkTransport"
)
)
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_1_1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry a bit about this one in particular as it's probably one the most often used, and the replacement expression is a bit of mouthful... But I agree about the tradeoff, it's for the better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a fair point. We don't want to become the capitalized() of GraphQL... Will think more about this

Base automatically changed from remove-closeable-dispatcher to main November 28, 2024 08: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.

3 participants