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

Update ApolloClient and ApolloRequest APIs from With-ers to Builders #3404

Merged
merged 13 commits into from
Oct 15, 2021

Conversation

BoD
Copy link
Contributor

@BoD BoD commented Oct 11, 2021

Related to #3301, this adds a proposal to implement a Buildersbased API instead of the current With-ers based on on the 3.x branch.

@BoD BoD changed the title Add Builders proposal to design-docs Update ApolloClient and ApolloRequest APIs from With-ers to Builders Oct 13, 2021
@BoD BoD marked this pull request as draft October 13, 2021 16:59
@BoD
Copy link
Contributor Author

BoD commented Oct 13, 2021

This PR is easier to read in a few steps:

  1. Make ApolloClient's API Builder based instead of With-er based (8126eaa and f68807b)
  2. Make ApolloRequest's API Builder based instead of With-er based (a81a3ba)
  3. Split ExecutionParameters in 2 interfaces: read-only and mutable (d1eefb8 and 84deb62)
  4. Rename all "with" extensions for consistency (59218b1)
  5. Add a temporary "compatibility layer" keeping the previous With-ers API available, to ease the transition (c2424fd)

What's left:

  • Update documentation and upgrade guide
  • Maybe some unit tests for the Builders

@martinbonnin
Copy link
Contributor

A few comments but looks good overall, Thanks!

For the HasExecutionContext, we might want to make everything val instead of fun

  • ApolloClient.sendApqExtensions() => val ApolloClient.sendApqExtensions
  • ApolloRequest.httpHeaders() => val ApolloClient.httpHeaders
  • etc...

Especially for properties that start with a verb, it makes it explicit that it's only a getter? Any thoughts?

@BoD
Copy link
Contributor Author

BoD commented Oct 14, 2021

A few comments but looks good overall, Thanks!

🙏

For the HasExecutionContext, we might want to make everything val instead of fun

  • ApolloClient.sendApqExtensions() => val ApolloClient.sendApqExtensions
  • ApolloRequest.httpHeaders() => val ApolloClient.httpHeaders
  • etc...

Especially for properties that start with a verb, it makes it explicit that it's only a getter? Any thoughts?

Yes, good idea! I first thought of renaming them getXyz, but making them vals instead is better and clear IMO.

Comment on lines +46 to +51
return networkTransport(networkTransport.copy(
engine = CachingHttpEngine(
directory = directory,
maxSize = maxSize,
delegate = networkTransport.engine
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Random thoughts: should we go Builders all the way down and convert HttpNetworkTransport to Builders as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not completely sure. Maybe we could come up with a rule of thumb like: if there are more than n possible parameters, let's have a builder, otherwise a regular constructor is enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are 2 strong arguments for Builders everywhere though:

  1. consistency
  2. java interop

@BoD BoD marked this pull request as ready for review October 15, 2021 11:41
@BoD BoD force-pushed the builders-instead-of-withers branch from 87b3b90 to 3c509ee Compare October 15, 2021 12:18
@BoD BoD merged commit ee151f7 into dev-3.x Oct 15, 2021
@BoD BoD deleted the builders-instead-of-withers branch October 15, 2021 12:59
@BoD
Copy link
Contributor Author

BoD commented Oct 15, 2021

(Another PR with further doc updates following this change will come later.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants