BREAKING CHANGE(generator): make dependency on ClassGraph optional #1733
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Description
We are using
ClassScanner
(which wrapsClassGraph
) to automatically resolve polymorphic types (i.e. given an interface we can find all implementing types that are available on classpath) and locate federated entities (i.e. types with@key
directive). This is generally great as this information can be pulled in automatically but it is a blocker for using the library with GraalVM.ClassGraph
is incompatible with GraalVm because when compiling to native image, we will no longer have JARs on classpath so any metadata around resources in those files will be invalid. Since we only use classpath scanning for resolving polyrmophic types and federated entities, the simplest solution is to provide users ability to manually provide this information without relying on theClassGraph
(which is still used by default). By no longer relying onClassGraph
we can now generate valid GraalVM reflect metadata and compile GraphQL Kotlin servers to native images.This PR introduces a breaking change that removes
SchemaGenerator#addAdditionalTypesWithAnnotation
function. This function was originally added to avoid exposingClassGraph
outside ofgraphql-kotlin-schema-generator
module and allow federation module to easily locate entity types. By makingClassGraph
dependency optional, function no longer makes sense.🔗 Related Issues