is there a bug in apollo 5 that does not generate ...
# apollo-kotlin
a
is there a bug in apollo 5 that does not generate data builders? default fake resolver is gone too https://www.apollographql.com/docs/kotlin/v5/testing/data-builders#configuring-default-field-values
m
Can you check your test source set?
We added the possibility to generate the sources in there
Because it makes more sense
a
ok ill build tests, i had one production usage of the builder I was able to fix. but
BaseFakeResolver
!=
DefaultFakeResolver
where I could pass
__Schema.all
what is the replacement now?
also this doc is wrong then:
Copy code
/**
   * Overrides the way the generated data builders are connected.
   * Use this if you want to connect the generated models to another task than the default destination.
   *
   * By default, the generated sources are connected to:
   * - main sourceSet for Kotlin projects
   * - commonMain sourceSet for Kotlin multiplatform projects
   * - main sourceSet for Android projects
   */
  fun dataBuildersOutputDirConnection(action: Action<in DirectoryConnection>)
since its connected to only test directories now
m
Yup, that doc is 100% wrong, I'll fix in in a bit
but
BaseFakeResolver
!=
DefaultFakeResolver
where I could pass
__Schema.all
what is the replacement now?
Looking into this
a
thanks . ive also tried connecting the data builder to main source via:
Copy code
dataBuildersOutputDirConnection { 
  connectToAllAndroidVariants()
}
however the task
Copy code
> Task :infra-apollo-schema:generateStorefrontDataBuildersApolloSources
is taking serveral minutes to run / not completing
m
Mmm that's not good
Can you hook a debugger and see where it's stuck?
a
it completed
Copy code
:infra-apollo-schema:generateStorefrontDataBuildersApolloSources | 13M43S | 46% | ████████████████████████████████████████████████████████████████████████████████
13 minutes 😖
slow parrot 1
m
I'm assuming it was faster before, right?
a
and the generated code is still only in unit test directory
Screenshot 2025-11-06 at 3.28.11 PM.png
m
I think this is an IDE issue
The sources are generated only once but wired to all the variants
And IJ/AS can only display one variant at a time (
unitTest
here)
Back to this:
> but
BaseFakeResolver
!=
DefaultFakeResolver
where I could pass
__Schema.all
what is the replacement now?
Trying to understand. Do you need to actively pass
__Schema.all
? If you extend
DefaultFakeResolver()
it should work. One example is here: https://github.com/apollographql/apollo-kotlin/blob/e994e2fb9eee52356c177f4bff55b8[…]ts/data-builders-kotlin/src/test/kotlin/test/DataBuilderTest.kt
a
ah i see. if thats true, then its showing up as red in the IDE and non autocompletable.
Copy code
Trying to understand. Do you need to actively pass __Schema.all?  If you extend DefaultFakeResolver() it should work. One example is here:
is this now code generated? previously wasnt
ah thats why
m
Yes, I'm trying to steer people away from using
__Schema
types. We added a bunch of stuff there over the year but never really thought it through
a
and its not autocompletable since the usage of it is in a main source set (testing module)
is there a way to unwire what the plugin was doing in terms of connecting to unit test directory, and just connecting to a single one? since I want the IDE to autocomplete, if i could do:
Copy code
dataBuildersOutputDirConnection {
   resetConnection()
   connectToAndroidSourceSet("main")
}
then id get IDE autocomplete
we use the main source set for mocking behind code logic in debug source set, using the data builders to make it easier to construct them
m
If you set
dataBuildersOutputDirConnection{}
this is what it is doing
a
oooo
m
It disables the default wiring
a
ok so i just set it to main oncee, i was doing all source sets
m
Yes
a
🤌👍
m
But Android "SourceSet" are weird. AGP really wants you to thing in terms of "components" now
Are you using AGP9?
a
not yet 8.11.1
👍 1
m
Good 🙂
we use the main source set for mocking behind code logic in debug source set, using the data builders to make it easier to construct them
I'm not sure I follow 100% here
At the end of the day, you have several "variants": • debug • release • unitTest • androidTest (IIRC)
Do you need the data builders in all the variants? Because this is what
connectToAndroidSourceSet("main")
should be doing. But AGP doesn't really want us to do this, I can't really remember why
a
sure. we have a testing module that exposes a fake resolver that applies custom logic for scalar adapters. its in main source set. then debug source set files in other modules declare a modk data operation in the network transport layer to return it instead:
Copy code
@ContributesTo(AppScope::class)
@Module
object ImmersiveCategoryMockModule {

    @Provides
    @IntoMap
    @MockOperationKey(GetCategoryBlockBuilderQuery::class)
    fun mockICPQuery(): MockOperation<*> = MockDataOperation(
        handlesRequest = { op: GetCategoryBlockBuilderQuery -> op.categoryId == "0" },
    ) { resolver, _ ->
        GetCategoryBlockBuilderQuery.Data(resolver = resolver) {
            blockBuilderCategoryExperience = buildBlockBuilderCategoryExperience {
                blocks = listOf(
                    buildBlockBuilderConfidenceBar { },
                    buildBlockBuilderGuide { },
                    buildBlockBuilderBanner { },
                    buildBlockBuilderBuyingGuideRow { },
                    buildBlockBuilderCardRow { },
                    buildBlockBuilderFreeShippingBanner { },
                )
            }
        }
    }
}
At the end of the day, you have several "variants":
• debug
• release
• unitTest
• androidTest (IIRC)
[3:41 PM]
Do you need the data builders in all the variants? Because this is what
connectToAndroidSourceSet("main")
should be doing. But AGP doesn't really want us to do this, I can't really remember why
yeah thats why it probably took a long time to compile. but interesting AGP doesnt want us to do this...
m
we have a testing module that exposes a fake resolver that applies custom logic for scalar adapters. its in main source set
Could you make this a non-android plain JVM module? Variants + libraries are adding a lot of complexity
Re: time. I don't think it depends on the number of variants. If the slow task is
generateFooDataBuilderSources
then it should be called only once for all variants.
a
yeah its much slower than in 4.x. youre right - makes sense now that it only is called once