Is your feature request related to a problem? Please describe.
graphql-kotlin-sdl-generator uses ServiceLoader to find SchemaGeneratorHooksProvider, but only allows a single match.
- Multiple
SchemaGeneratorHooksProvider configured on the classpath (in META-INF/services/) makes the plugin throw an exception, no questions asked. The plugin does not provide a way set precedence for multiple matches.
- If any library on the classpath (built on top of
graphql-kotlin) defines SchemaGeneratorHooksProvider service, users have no choice but to exclude that library (or make an ugly workaround with the shade plugin) if they want to redefine it.
Describe the solution you'd like
To be able to set a clear precedence when multiple SchemaGeneratorHooksProviders are defined. I would propose a solution similar to the @Primary and @Order annotations of the Spring Framework. The library can define it's own annotations or can consider to support the javax.annotation.Priority as well.
Example implementation:
ServiceLoader.load(SchemaGeneratorHooksProvider::class.java)
.maxByOrNull { it::class.findAnnotation<Priority>()?.value ?: 0 }
Describe alternatives you've considered
As an alternative, we could play around with the ClassLoader mechanism, maybe to prefer definitions from the current project over the ones coming from the libraries. I haven't looked into the feasibility of this idea, however.
Is your feature request related to a problem? Please describe.
graphql-kotlin-sdl-generatorusesServiceLoaderto findSchemaGeneratorHooksProvider, but only allows a single match.SchemaGeneratorHooksProviderconfigured on the classpath (inMETA-INF/services/) makes the plugin throw an exception, no questions asked. The plugin does not provide a way set precedence for multiple matches.graphql-kotlin) definesSchemaGeneratorHooksProviderservice, users have no choice but to exclude that library (or make an ugly workaround with the shade plugin) if they want to redefine it.Describe the solution you'd like
To be able to set a clear precedence when multiple
SchemaGeneratorHooksProviders are defined. I would propose a solution similar to the@Primaryand@Orderannotations of the Spring Framework. The library can define it's own annotations or can consider to support thejavax.annotation.Priorityas well.Example implementation:
Describe alternatives you've considered
As an alternative, we could play around with the
ClassLoadermechanism, maybe to prefer definitions from the current project over the ones coming from the libraries. I haven't looked into the feasibility of this idea, however.