-
Notifications
You must be signed in to change notification settings - Fork 655
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
Fluent query API #3447
Fluent query API #3447
Conversation
apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/ApolloClient.kt
Outdated
Show resolved
Hide resolved
apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/ApolloClient.kt
Outdated
Show resolved
Hide resolved
apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo3/ApolloCall.kt
Outdated
Show resolved
Hide resolved
I like it!
Indeed we can see in the tests that the custom cases look a lot nicer! For the simple case, we could add a
|
…/ApolloClient.kt Co-authored-by: Benoit Lubek <[email protected]>
Let's see the feedback we have until committing to more API? It's always easier to add than remove... |
This PR serves as a RFC for a new
ApolloCall
type to make the API more fluent. It's hopefully the last big API-breaking change now that #3301 is done. AnApolloCall
is a simple wrapper around a (ApolloRequest
+ApolloClient
). It can be configured, is self contained and contains everything needed to execute the query and return a response.It's slightly more verbose if no customization is done (having to add the extra
.execute()
) but it's a lot less verbose as soon as any customization is required.I personally like how it makes tests easier to write but the more feedback we get, the better.
Current code:
Fluent (new) code:
This API is also closer to what was done in 2.x and plays nicer with
RxJava
:On the drawbacks side, it's one more type (
ApolloCall
) to maintain that needs to implementHasMutableExecutionContext
. It should cause any performance regression but it's more code and increases the API surface. I've thought of makingApolloRequest
internal to reduce the API surface a bit but it's still used as part of theApolloInterceptor
API so it's not really possible.Let us know what you think!