Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE(generator): make dependency on ClassGraph optional #1733

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

dariuszkuc
Copy link
Collaborator

@dariuszkuc dariuszkuc commented Mar 27, 2023

📝 Description

We are using ClassScanner (which wraps ClassGraph) 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 the ClassGraph (which is still used by default). By no longer relying on ClassGraph 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 exposing ClassGraph outside of graphql-kotlin-schema-generator module and allow federation module to easily locate entity types. By making ClassGraph dependency optional, function no longer makes sense.

🔗 Related Issues

We are using `ClassScanner` (which wraps `ClassGraph`) 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 the `ClassGraph` (which is still used by default).

This PR introduces a breaking change that removes `SchemaGenerator#addAdditionalTypesWithAnnotation` function. This function was originally to avoid exposing `ClassGraph` outside of `graphql-kotlin-schema-generator` module and allow federation module to easily locate entity types. By making `ClassGraph` dependency optional, function no longer makes sense
.

Related:

* ExpediaGroup#1543
* ExpediaGroup#1441
* ExpediaGroup#1224
@dariuszkuc dariuszkuc added changes: major Changes require a major version module: generator Issue affects the schema generator and federation code labels Mar 27, 2023
@dariuszkuc dariuszkuc enabled auto-merge (squash) March 27, 2023 03:06
@dariuszkuc dariuszkuc changed the title BREAKING CHANGE(generator): make dependency on ClassGraphClass optional BREAKING CHANGE(generator): make dependency on ClassGraph optional Mar 27, 2023
@dariuszkuc dariuszkuc disabled auto-merge March 27, 2023 03:07
@dariuszkuc dariuszkuc enabled auto-merge (squash) March 27, 2023 03:07
@dariuszkuc dariuszkuc merged commit 6f9b4b1 into ExpediaGroup:master Mar 30, 2023
@dariuszkuc dariuszkuc deleted the typeResolver branch March 30, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: major Changes require a major version module: generator Issue affects the schema generator and federation code
Development

Successfully merging this pull request may close these issues.

2 participants