Is it not possible to use the test builders in non...
# apollo-kotlin
s
Is it not possible to use the test builders in non-test code? It is now generated in the test resources only. For our app we basically have a module called testdata where we have a ton of convenience builders (basically what test builders do, but we had to write them by hand which would be great if we could skip that from now on) which we use to make fake data when we test our app in some sort of “dev” mode. I was hoping we could use this functionality instead. Is there a way to generate them not only for the test sources?
m
You can use
testDirConnection
(source code):
Copy code
apollo {
  generateTestBuilders.set(true)

  testDirConnection {
    connectToAndroidSourceSet("main")
    // or for non-Android projects
    // connectToKotlinSourceSet("main")
    // or for multiplatform projects
    // connectToKotlinSourceSet("jvmMain")
  }
}
s
Right, this seems to be working! Gradle always feels like magic to me, never would have figured this out by myself, even after reading the documentation. Thank you! I see that there is the “ApolloExperimental” annotation to them too. Is it due to the fact that you want to battle test them a bit more for safety, or do you have some plans in mind that you’re anticipating will change the APIs in a non-backwards compatible way?
m
Mostly battle-testing. We'll try to do this more moving forward: add new APIs behind a
@ApolloExperimental
annotation for early adopters to try them and give feedback and then drop it down the road
Gradle is super magic. Kotlin scripts and autocomplete does help a little bit if you can enable them
s
Yeah I have it enabled but every time I think I get it, I realize I don’t 😂 Thanks for the help! And I like the idea of the annotation if it means we get to try more cool stuff like this!