apollo-kotlin icon indicating copy to clipboard operation
apollo-kotlin copied to clipboard

Need no-op debug server

Open ber4444 opened this issue 1 year ago • 1 comments

Use case

import com.apollographql.apollo3.debugserver.ApolloDebugServer will break the release builds since your docs suggest to only include this dependency in the debug build type

Describe the solution you'd like

releaseImplementation("com.apollographql.apollo3:apollo-debug-server-noop:4.0.0-beta.4")

ber4444 avatar Feb 22 '24 11:02 ber4444

Hi!

You should be able to have the import only in your debug build, by doing something like this:

app/src/debug/kotlin/yourpackage/ApolloDebugServer.kt:

fun ApolloClient.registerApolloDebugServer() {
    ApolloDebugServer.registerApolloClient(this)
}

app/src/main/kotlin/yourpackage/ApolloDebugServer.kt:

fun ApolloClient.registerApolloDebugServer() {
    // no-op
}

and call it where you configure your client:

val apolloClient = ApolloClient.Builder() 
  // (...)
  .build()
  .registerApolloDebugServer()

Here’s an example of that, albeit a tad more complicated because it’s a KMP app.

Would that work for you?

BoD avatar Feb 22 '24 11:02 BoD

Excellent, thanks!

ber4444 avatar Feb 22 '24 23:02 ber4444