Hi :wave: I've been running into a graph verificat...
# koin
f
Hi 👋 I've been running into a graph verification issue after introducing a data class holding boolean feature flags. After looking into the issue, I noticed that graph verification tests whitelist several primitives, but not
Boolean
. Is there a reason for that? https://github.com/InsertKoinIO/koin/blob/main/projects/core/koin-test/src/jvmMain/kotlin/org/koin/test/verify/VerifyModule.kt#L39-L42
My data class is actually pretty simple:
Copy code
data class FeatureFlags(
    val enableFavorites: Boolean,
    val enableSharing: Boolean
)
I inject an instance of it in my top level app module:
Copy code
val appModule = module {
    single {
        FeatureFlags(
            enableFavorites = false,
            enableSharing = false
        )
    }
}
It fails with
Copy code
|-> definition [Singleton:'at.orf.kids.core.common.FeatureFlags']
| bind types: [class at.orf.kids.core.common.FeatureFlags]
| 2 dependencies to check
* ----- > Missing definition type 'kotlin.Boolean' in definition '[Singleton:'at.orf.kids.core.common.FeatureFlags']'
Fix your Koin configuration or add extraTypes parameter to whitelist the type: verify(extraTypes = listOf(kotlin.Boolean::class))
It feels a bit "unsafe" to globally whitelist
Boolean
because if I fetch one somewhere, without satisfying the dependency, it would be a failure I want to catch. But this is not the case here, since I manually provide dependencies.
How could I work around that?
a
Yeah. For this we would need to whitelist one by one the case. Either a main whitelist ... which is the case for common Android types.
I was wondering a way to help you fill missing parts for injected params: display an error message saying that this dependency is missing, but also generate the line to declare the injection to verify
this way if we miss something, either it's a injected parameter and you have just to copy paste the code. Either, it's a real case
wdyt?
f
Hmm, I'm not sure I understand. Is it already possible to whitelist just the parameters of a specific dependency, i.e. all
Boolean
parameters for my
FeatureFlags
dependency?
a
yeah would be something like delcaring what injection you would whitelist by hand
Copy code
parameterInjections {
    to<FeatureFlags>( Boolean::class )
}
then we would know that injecting
Boolean
in
FeatureFlags
is ok
f
Yeah, I agree. That would limit the verification scope tight enough 👌
a
cool 👍