If I have missing bindings, could I use <https://d...
# dagger
g
If I have missing bindings, could I use https://dagger.dev/dev-guide/spi to find out what those missing bindings are and generate new dagger modules which will fix those?
a
Yes you can enable fullBindingGraphValidation. Then dagger will call your SPI with missing binding information available.
g
Thanks!
@Arun I've applied the plugin on my app module (android) but I seem to see only the graph of the module itself and not the whole graph that is created for the whole app. Basically, I removed one dagger module from the app module that supplies an instance to an interface set in another module, and I am would like to generate that dagger module instead of writing it. I tried the following (from your examples online) but I can't seem to catch the whole graph, once it is totally resolved, and filter the really missing bindings:
Copy code
bindingGraph?.network()?.nodes()
    ?.groupBy(BindingGraph.Node::componentPath)
    ?.forEach { (componentPath, nodes) ->
        nodes.forEach {
            println("Node = $it")
     }
}
For example, if my missing binding is
AccountConfigRepository
, I can't find it in what is printed here, but I still get it from Dagger as an error. What am I missing?
And I've enabled
fullBindingGraphValidation
:
Copy code
kapt {
    arguments {
        arg("dagger.fullBindingGraphValidation", "ERROR")
    }
}
Ok, I do see only components and bindings of the app module itself, even with this flag on (unless I didn't turn it on correctly), so that's my issue
a
@galex please try
arg("dagger.fullBindingGraphValidation", "WARNING")
instead as I think, ERROR will exit early. You need to validation to ignore the missing binding error so that your spi plugin can process the invalid graph. Also note that your SPI plugin will be called twice, one for full graph and one for actual graph https://github.com/google/dagger/issues/1711#issuecomment-580831487 THe missing binding will be only available in the full graph and not the final graph. You can compare with my impl in one of my projects where I added missing binding visualization https://github.com/arunkumar9t2/scabbard/releases/tag/0.5.0
g
Thank you @Arun ! I have doubts about what I want is actually possible, because the errors are thrown from Hilt, not Dagger, so maybe I am actually looking for a hilt-spi plugin but I don't think this exists 😨