diff --git a/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/CdiLookupService.java b/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/CdiLookupService.java index 3157a9acc..fd1a6b6e9 100644 --- a/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/CdiLookupService.java +++ b/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/CdiLookupService.java @@ -26,4 +26,9 @@ public Class getClass(Class declaringClass) { public Object getInstance(Class declaringClass) { return CDI.current().select(declaringClass).get(); } + + @Override + public boolean isResolvable(Class declaringClass) { + return CDI.current().select(declaringClass).isResolvable(); + } } diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index 51d863d23..b73fe0b9c 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -139,10 +139,8 @@ private void verifyInjectionIsAvailable() { .flatMap(stream -> stream) .distinct().forEach(beanClassName -> { // verify that the bean is injectable - try { - lookupService.getClass(classloadingService.loadClass(beanClassName)); - } catch (Exception e) { - throw SmallRyeGraphQLServerMessages.msg.canNotInjectClass(beanClassName, e); + if (!lookupService.isResolvable(classloadingService.loadClass(beanClassName))) { + throw SmallRyeGraphQLServerMessages.msg.canNotInjectClass(beanClassName, null); } }); } diff --git a/server/implementation/src/main/java/io/smallrye/graphql/spi/LookupService.java b/server/implementation/src/main/java/io/smallrye/graphql/spi/LookupService.java index 7788c6d01..80a73a130 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/spi/LookupService.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/spi/LookupService.java @@ -40,6 +40,8 @@ static LookupService load() { Object getInstance(Class declaringClass); + boolean isResolvable(Class declaringClass); + /** * Default Lookup service that gets used when none is provided with SPI. * This use reflection @@ -65,5 +67,10 @@ public Object getInstance(Class declaringClass) { throw msg.countNotGetInstance(ex); } } + + @Override + public boolean isResolvable(Class declaringClass) { + return true; + } } }