Open mzuber opened 11 months ago
/cc @FroMage (panache), @jmartisk (graphql), @loicmathieu (panache), @phillip-kruger (graphql)
When using classes from a dependency inside your graphql api, that dependency must be explicitly added to the index (with few exceptions) Try adding this to your configuration
quarkus.index-dependency.panache.group-id=io.quarkus
quarkus.index-dependency.panache.artifact-id=quarkus-panache-common
It looks like an usage that could be common, I'm thinking we could add this enum to the index automatically.
Yeah that makes sense I guess. @mskacelik will create a PR with that
@mskacelik the idea would be to use AdditionalIndexedClassesBuildItem
in the Panache module.
Why in Panache? Don't we want this in GraphQL, because it's most likely needed because of using it inside a GraphQL api?
I'm not sure if we have a capability for Panache but if we have one (or if you feel like adding one) then yes we can do it in Panache GraphQL.
But I think the class needs to be in the classpath to be added to the index so you need to check (and let's not check with a class loader call if we can avoid it).
When using classes from a dependency inside your graphql api, that dependency must be explicitly added to the index (with few exceptions) Try adding this to your configuration
quarkus.index-dependency.panache.group-id=io.quarkus quarkus.index-dependency.panache.artifact-id=quarkus-panache-common
@jmartisk Thanks, this did the trick. Do you think there is value in adding a note to the SmallRye GraphQL guide on this? Happy to provide a PR.
@gsmet There are capabilities for MONGODB_PANACHE
and MONGODB_PANACHE_KOTLIN
. I assume we could add separate capabilities for HIBERNATE_ORM_PANACHE
, HIBERNATE_REACTIVE_PANACHE
, HIBERNATE_ORM_PANACHE_KOTLIN
, HIBERNATE_REACTIVE_PANACHE_KOTLIN
and assume that if one of these six is present, then the class is present? We wanted to simply use QuarkusClassLoader.isClassPresentAtRuntime
, is that bad?
@mzuber we could add something to additional notes (https://quarkus.io/guides/smallrye-graphql#additional-notes), probably not specifically about Panache, but more generally about using stuff from dependencies. This specific case might go away if we really start adding that enum into the index automatically.
I don't think GraphQL needs this info ? Maybe the fix is the GraphQL just ignore the error ? If possible ?
Well, can it work with this error? What does the graphql look like if the error is ignored? If that causes the method to be ignored, that's probably not what we want, no?
Describe the bug
Using the
Sort.Direction
enum from thequarkus-hibernate-orm-panache
extension as a method parameter for a GraphQL query defined with thequarkus-smallrye-graphql
extension results in a startup failure when Quarkus tries to generate the schema of the exposed GraphQL API at application startup:Expected behavior
It is possible to use the
Sort.Direction
enum from thequarkus-hibernate-orm-panache
as a method parameter for a GraphQL query.Actual behavior
The
quarkus-smallrye-graphql
extension is unable to generate the schema of the exposed GraphQL API at application startup. Before the startup failure the warningClass [io.quarkus.panache.common.Sort$Direction] is not indexed in Jandex. Can not scan Object Type, might not be mapped correctly. Kind = [CLASS]
is logged.How to Reproduce?
In a Quarkus application using both the
quarkus-hibernate-orm-panache
and thequarkus-smallrye-graphql
extension, define a GraphQL API using theSort.Direction
enum in a query definition:Output of
uname -a
orver
No response
Output of
java -version
openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12) OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)
Quarkus version or git rev
3.4.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.3
Additional information
No response