I've created my own compiler plugin, but now I wou...
# apollo-kotlin
j
I've created my own compiler plugin, but now I would like to try the 'modern' normalized cache library and its cache plugin. The docs say to wrap the plugin and call them from a main plugin. Thats fine, I am happy to do that from my own compiler plugin and delegate some to the cache plugin. However, just the act of loading the dependency
Copy code
api(libs.apollo.cache.plugin)
Results in the error: "Apollo: only a single compiler plugin provider is allowed" How am I supposed to wrap the plugin?
I guess I can do something like:
Copy code
tasks.withType<Jar>().configureEach {
    exclude("META-INF/services/com.apollographql.apollo.compiler.ApolloCompilerPluginProvider")
}
m
Apologies, that's indeed a blind spot.
Excluding the resource is the way to go
v5 has a way to use multiple plugins but it's not available in v4. We should probably backport it
j
I’d really appreciate backporting it
m
Yup, that's fair. Making this backward compatible will require a bit of care though. Will dive into this next week. You can follow https://github.com/apollographql/apollo-kotlin/issues/6534 for updates
gratitude thank you 1
This is now possible in 4.3.0. A new release of the cache is also in the pipe
🙌 1
b
The new cache
1.0.0-alpha.3
is available.
🙌 1
j
forgot to update you two but I've been able to pull in 4.3 and the alpha3 cache, thanks for pulling the compiler refactor in. still need to test out the cache plugin with the directive policies a bit more but hoping to get to that soon
👍 2
One thing I am still confused about is why it doesnt seem like we allow configuration of multiple compiler plugins within the apollo dsl. Why do we continue to have "Apollo: only one Apollo Compiler Plugin is allowed." Should I still be making a wrapper plugin which configures each plugin I might want to include? Is there a way to just reference the registry or default plugin which wraps the registry?
b
I think for now you can just add
implementation("com.apollographql.cache:normalized-cache-apollo-compiler-plugin:1.0.0-alpha.4")
to your own plugin and that should work. But yeah we might want to make that API a bit smoother for v5 and maybe just allow calling
plugin()
multiple times.
j
yea I think it works referencing any plugin that has dependencies on others, its just confusing - that could help. agreed - can be just for v5
m
v5 has this already actually. You should be able to register multiple plugins there.
gratitude thank you 1
That should be in
5.0.0-alpha.1
FWIW, the problem we had was how to express dependencies between multiple plugins. In v5, you can now use "ids" and before/after relationships.
But it's a tough problem since plugins, by definition do not know about each other (by default) so everything must be somewhat loosely coupled.
Also oops, as @bod just pointed out, while the underlying infrastructure is there, the Gradle plugin still has a check preventing multiple compiler plugins. There are ways to work around if you want to test with
5.0.0-alpha.1
but I'll fix this for
5.0.0-alpha.2
j
I dont need to upgrade right away, I've worked around it for now! just got done upgrading to 4.3 and the new cache recently enough, probably cant take on another major version update just yet
👍 1