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

GraphQL Typesafe client with sources in a dependency #44550

Closed
jmini opened this issue Nov 17, 2024 · 9 comments · Fixed by #45351
Closed

GraphQL Typesafe client with sources in a dependency #44550

jmini opened this issue Nov 17, 2024 · 9 comments · Fixed by #45351
Labels
area/graphql area/jbang Issues related to when using jbang.dev with Quarkus area/smallrye
Milestone

Comments

@jmini
Copy link
Contributor

jmini commented Nov 17, 2024

When having the typesafe client sources (an interface with the @GraphQLClientApi annotation and model classes) inside my quarkus project everything works great. I can inject the client like this:

@Inject
WorkitemClientApi api;

See docs: https://quarkus.io/guides/smallrye-graphql-client


Example project for calling the GitLab GraphQL endpoint:
quarkus-graphql-client 
(on branch main commit 9b2fcec)


Now I would like to put my sources in a dedicated library:

Example project: gitlab-workitem-graphql-client



Can be loaded with jitpack as:



com.github.unblu:gitlab-workitem-graphql-client:0dde568aa4

Gradle config of the quarkus project

repositories {
    maven {
        url 'https://jitpack.io'
        content {
            includeGroup 'com.github.unblu'
        }
    }
    mavenCentral()
    // mavenLocal()
}

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-rest'
    implementation 'io.quarkus:quarkus-smallrye-graphql-client'
    implementation 'io.quarkus:quarkus-arc'
    implementation 'com.github.unblu:gitlab-workitem-graphql-client:0dde568aa43f45079cc646b23fed8c807fe7fa1a'
    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
}

Maven config of the quarkus project

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.acme</groupId>
    <artifactId>quarkus-graphql-client-maven</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <compiler-plugin.version>3.13.0</compiler-plugin.version>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
        <quarkus.platform.version>3.16.3</quarkus.platform.version>
        <skipITs>true</skipITs>
        <surefire-plugin.version>3.5.0</surefire-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.unblu</groupId>
            <artifactId>gitlab-workitem-graphql-client</artifactId>
            <version>0dde568aa43f45079cc646b23fed8c807fe7fa1a</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-smallrye-graphql-client</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                            <goal>generate-code</goal>
                            <goal>generate-code-tests</goal>
                            <goal>native-image-agent</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <parameters>true</parameters>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <properties>
                <skipITs>false</skipITs>
                <quarkus.native.enabled>true</quarkus.native.enabled>
            </properties>
        </profile>
    </profiles>
</project>




Test of the typesafe client outside of quarkus in a simple Jbang script

///usr/bin/env jbang "$0" "$@" ; exit $?

//DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/0dde568aa43f45079cc646b23fed8c807fe7fa1a
//DEPS io.smallrye:smallrye-graphql-client-implementation-vertx:2.11.0
//JAVA 11

import static java.lang.System.*;

import graphql.gitlab.api.WorkitemClientApi;
import graphql.gitlab.model.Group;
import graphql.gitlab.model.Project;
import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;

public class run {

    public static void main(String... args) {
        out.println("Start");
        var api = createApi();
        Project response = api.project("tech-marketing/demos/gitlab-agile-demo/initech/music-store/parent-portal", true, null);
        out.println(response);
        System.exit(0);
    }

    private static WorkitemClientApi createApi() {
        return TypesafeGraphQLClientBuilder.newBuilder()
                .endpoint("https://gitlab.com/api/graphql")
                .build(WorkitemClientApi.class);
    }
}


But when I try to include this library in my quarkus project, It fail during startup.



ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]


Example project for calling the GitLab GraphQL endpoint:
quarkus-graphql-client 
(on branch external-library commit 1254ebc)

Complete Quarkus App logs

2024-11-17 10:50:00,451 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation awardEmojiAdd($arg0: AwardEmojiAddInput!) { awardEmojiAdd(input: $arg0) {awardEmoji {name unicode unicodeVersion} errors} }
2024-11-17 10:50:00,455 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation createNote($arg0: CreateNoteInput!) { createNote(input: $arg0) {errors note {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}} }
2024-11-17 10:50:00,457 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation destroyNote($arg0: DestroyNoteInput!) { destroyNote(input: $arg0) {errors note {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}} }
2024-11-17 10:50:00,500 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation workItemRemoveLinkedItems($arg0: WorkItemRemoveLinkedItemsInput!) { workItemRemoveLinkedItems(input: $arg0) {errors message workItem {archived closedAt confidential createdAt id iid lockVersion namespace {fullPath id visibility} reference state title updatedAt webUrl widgets{__typename ... on WorkItemWidgetAssignees {assignees {nodes {id username}} type} ... on WorkItemWidgetAwardEmoji {type} ... on WorkItemWidgetColor {type} ... on WorkItemWidgetCrmContacts {type} ... on WorkItemWidgetCurrentUserTodos {type} ... on WorkItemWidgetDescription {description} ... on WorkItemWidgetDesigns {type} ... on WorkItemWidgetDevelopment {type} ... on WorkItemWidgetEmailParticipants {type} ... on WorkItemWidgetHealthStatus {type} ... on WorkItemWidgetHierarchy {ancestors {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} children {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} parent {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} ... on WorkItemWidgetIteration {type} ... on WorkItemWidgetLabels {labels {count nodes {color description id textColor title} pageInfo {endCursor hasNextPage startCursor}} type} ... on WorkItemWidgetLinkedItems {linkedItems {nodes {linkCreatedAt linkId linkType linkUpdatedAt workItem {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}}} type} ... on WorkItemWidgetMilestone {type} ... on WorkItemWidgetNotes {discussions {nodes {id notes {nodes {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}}}} type} ... on WorkItemWidgetNotifications {type} ... on WorkItemWidgetParticipants {type} ... on WorkItemWidgetRolledupDates {type} ... on WorkItemWidgetStartAndDueDate {dueDate startDate type} ... on WorkItemWidgetStatus {status} ... on WorkItemWidgetTimeTracking {type} ... on WorkItemWidgetWeight {type}} workItemType {id name}}} }
2024-11-17 10:50:00,516 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation workItemUpdate($arg0: WorkItemUpdateInput!) { workItemUpdate(input: $arg0) {errors workItem {archived closedAt confidential createdAt id iid lockVersion namespace {fullPath id visibility} reference state title updatedAt webUrl widgets{__typename ... on WorkItemWidgetAssignees {assignees {nodes {id username}} type} ... on WorkItemWidgetAwardEmoji {type} ... on WorkItemWidgetColor {type} ... on WorkItemWidgetCrmContacts {type} ... on WorkItemWidgetCurrentUserTodos {type} ... on WorkItemWidgetDescription {description} ... on WorkItemWidgetDesigns {type} ... on WorkItemWidgetDevelopment {type} ... on WorkItemWidgetEmailParticipants {type} ... on WorkItemWidgetHealthStatus {type} ... on WorkItemWidgetHierarchy {ancestors {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} children {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} parent {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} ... on WorkItemWidgetIteration {type} ... on WorkItemWidgetLabels {labels {count nodes {color description id textColor title} pageInfo {endCursor hasNextPage startCursor}} type} ... on WorkItemWidgetLinkedItems {linkedItems {nodes {linkCreatedAt linkId linkType linkUpdatedAt workItem {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}}} type} ... on WorkItemWidgetMilestone {type} ... on WorkItemWidgetNotes {discussions {nodes {id notes {nodes {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}}}} type} ... on WorkItemWidgetNotifications {type} ... on WorkItemWidgetParticipants {type} ... on WorkItemWidgetRolledupDates {type} ... on WorkItemWidgetStartAndDueDate {dueDate startDate type} ... on WorkItemWidgetStatus {status} ... on WorkItemWidgetTimeTracking {type} ... on WorkItemWidgetWeight {type}} workItemType {id name}}} }
2024-11-17 10:50:00,522 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: query workItemsByReference($arg0: ID, $arg1: [String!]!, $arg2: NotesFilterType) { workItemsByReference(contextNamespacePath: $arg0, refs: $arg1) {count nodes {archived closedAt confidential createdAt id iid lockVersion namespace {fullPath id visibility} reference state title updatedAt webUrl widgets{__typename ... on WorkItemWidgetAssignees {assignees {nodes {id username}} type} ... on WorkItemWidgetAwardEmoji {type} ... on WorkItemWidgetColor {type} ... on WorkItemWidgetCrmContacts {type} ... on WorkItemWidgetCurrentUserTodos {type} ... on WorkItemWidgetDescription {description} ... on WorkItemWidgetDesigns {type} ... on WorkItemWidgetDevelopment {type} ... on WorkItemWidgetEmailParticipants {type} ... on WorkItemWidgetHealthStatus {type} ... on WorkItemWidgetHierarchy {ancestors {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} children {count nodes {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} parent {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}} ... on WorkItemWidgetIteration {type} ... on WorkItemWidgetLabels {labels {count nodes {color description id textColor title} pageInfo {endCursor hasNextPage startCursor}} type} ... on WorkItemWidgetLinkedItems {linkedItems {nodes {linkCreatedAt linkId linkType linkUpdatedAt workItem {archived confidential createdAt id iid namespace {fullPath id visibility} reference state title webUrl workItemType {id name}}}} type} ... on WorkItemWidgetMilestone {type} ... on WorkItemWidgetNotes {discussions(filter: $arg2) {nodes {id notes {nodes {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}}}} type} ... on WorkItemWidgetNotifications {type} ... on WorkItemWidgetParticipants {type} ... on WorkItemWidgetRolledupDates {type} ... on WorkItemWidgetStartAndDueDate {dueDate startDate type} ... on WorkItemWidgetStatus {status} ... on WorkItemWidgetTimeTracking {type} ... on WorkItemWidgetWeight {type}} workItemType {id name}}} }
     2024-11-17 10:50:00,713 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
<====2024-11-17 10:50:01,118 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1576)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:338)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:178)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:492)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:546)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:698)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:323)
        ... 12 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:354)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:272)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:62)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:89)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:428)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:55)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1576)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:338)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:178)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:492)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:546)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:698)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:323)
        ... 12 more

        at io.quarkus.builder.Execution.run(Execution.java:124)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:161)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:350)
        ... 9 more
Caused by: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1576)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:338)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:178)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:492)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type graphql.gitlab.api.WorkitemClientApi and qualifiers [@Default]
        - injection target: gitlab.GreetingResource#api
        - declared on CLASS bean [types=[java.lang.Object, gitlab.GreetingResource], qualifiers=[@Default, @Any], target=gitlab.GreetingResource]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:546)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:698)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:323)
        ... 12 more

@quarkus-bot quarkus-bot bot added area/graphql area/jbang Issues related to when using jbang.dev with Quarkus area/smallrye labels Nov 17, 2024
Copy link

quarkus-bot bot commented Nov 17, 2024

/cc @jmartisk (graphql), @maxandersen (jbang), @phillip-kruger (graphql), @quarkusio/devtools (jbang)

jmini added a commit to jmini/gitlab-experiments that referenced this issue Nov 17, 2024
@jmini
Copy link
Contributor Author

jmini commented Nov 18, 2024

What is wired is that in the build log we see entries like that:

2024-11-18 06:41:51,794 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation awardEmojiAdd($arg0: AwardEmojiAddInput!) { awardEmojiAdd(input: $arg0) {awardEmoji {name unicode unicodeVersion} errors} }
06:41:51,794 io.smallrye.graphql.client.model.ClientModelBuilder.lambda$generateClientModels$0:70 (build-25) DEBUG ClientModelBuilder:70 - [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation awardEmojiAdd($arg0: AwardEmojiAddInput!) { awardEmojiAdd(input: $arg0) {awardEmoji {name unicode unicodeVersion} errors} }
2024-11-18 06:41:51,806 DEBUG [io.sma.gra.cli.mod.ClientModelBuilder] (build-25) [graphql.gitlab.api.WorkitemClientApi] – Query created: mutation createNote($arg0: CreateNoteInput!) { createNote(input: $arg0) {errors note {author {id username} awardEmoji {nodes {name unicode unicodeVersion}} body id}} }

So I guess this build step is executed:

@BuildStep
@Record(RUNTIME_INIT)
void buildClientModel(CombinedIndexBuildItem index, SmallRyeGraphQLClientRecorder recorder,
BuildProducer<SyntheticBeanBuildItem> syntheticBeans, GraphQLClientBuildConfig quarkusConfig) {
if (!index.getIndex().getAnnotations(GRAPHQL_CLIENT_API).isEmpty()) {
ClientModels clientModels = (quarkusConfig.enableBuildTimeScanning) ? ClientModelBuilder.build(index.getIndex())
: new ClientModels(); // empty Client Model(s)
RuntimeValue<ClientModels> modelRuntimeClientModel = recorder.getRuntimeClientModel(clientModels);
DotName supportClassName = DotName.createSimple(ClientModels.class.getName());
SyntheticBeanBuildItem bean = SyntheticBeanBuildItem
.configure(supportClassName)
.addType(supportClassName)
.scope(Singleton.class)
.runtimeValue(modelRuntimeClientModel)
.setRuntimeInit()
.unremovable()
.done();
syntheticBeans.produce(bean);
}
}

But somehow not available when the quarkus app is starting.

@jmartisk
Copy link
Contributor

Does the library contain a META-INF/beans.xml file? That is required I think

@jmini
Copy link
Contributor Author

jmini commented Nov 18, 2024

I added a Jandex index, but no META-INF/beans.xml. What should that file contains?

According to https://quarkus.io/guides/cdi-reference#bean_discovery they say:

dependencies that contain a beans.xml descriptor (content is ignored)

@jmartisk
Copy link
Contributor

"Content is ignored" means it can be empty :)

jmini added a commit to unblu/gitlab-workitem-graphql-client that referenced this issue Nov 18, 2024
@jmini
Copy link
Contributor Author

jmini commented Nov 18, 2024

Indeed.

I understood the docs https://quarkus.io/guides/cdi-reference#bean_discovery as META-INF/jandex.idx being enough (it is a separated bullet point) but it seems that META-INF/beans.xml is mandatory.

@jmartisk jmartisk closed this as completed Dec 2, 2024
@aloubyansky
Copy link
Member

META-INF/jandex.idx should indeed be enough. If it's not, it looks like it's an issue

jmini added a commit to jmini/gitlab-experiments that referenced this issue Dec 30, 2024
@jmini
Copy link
Contributor Author

jmini commented Dec 30, 2024

@aloubyansky @jmartisk should this issue be re-opened?


Given the commit history of my test lib:
https://github.com/unblu/gitlab-workitem-graphql-client/commits/main/

I have different versions of my test lib gitlab-workitem-graphql-client (containing the GraphQL client model and interface) built by JitPack.

Version 0dde568

com.github.unblu:gitlab-workitem-graphql-client:0dde568aa4

Does have:

  • a jandex index file: META-INF/jandex.idx
  • no META-INF/beans.xml file
File list in "gitlab-workitem-graphql-client-0dde568aa4.jar"

jar -tf ~/.m2/repository/com/github/unblu/gitlab-workitem-graphql-client/0dde568aa4/gitlab-workitem-graphql-client-0dde568aa4.jar

META-INF/
META-INF/MANIFEST.MF
graphql/
graphql/gitlab/
graphql/gitlab/api/
graphql/gitlab/api/WorkitemClientApi.class
graphql/gitlab/model/
graphql/gitlab/model/<...>.class
graphql/gitlab/model/<...>.class
...
graphql/gitlab/model/<...>.class
META-INF/jandex.idx
logging.properties

Version 5964fd4138

com.github.unblu:gitlab-workitem-graphql-client:5964fd4138

Does have:

  • a jandex index file: META-INF/jandex.idx
  • a dummy file (containing only a comment): META-INF/beans.xml
File list in "gitlab-workitem-graphql-client-0dde568aa4.jar"

jar -tf ~/.m2/repository/com/github/unblu/gitlab-workitem-graphql-client/5964fd4138/gitlab-workitem-graphql-client-5964fd4138.jar

META-INF/
META-INF/MANIFEST.MF
graphql/
graphql/gitlab/
graphql/gitlab/model/
graphql/gitlab/model/<...>.class
graphql/gitlab/model/<...>.class
...
graphql/gitlab/model/<...>.class
graphql/gitlab/api/
graphql/gitlab/api/WorkitemClientApi.class
logging.properties
META-INF/jandex.idx
META-INF/beans.xml


My test project (updated to quarkus 3.17.5):

So right now I would say that Quarkus requires the META-INF/beans.xml file to be present


I happy to contribute at least a test case if you point me to the place where those should be located, and how you manage those "external libraries" in the test suite (I guess you prefer something either built locally or published on maven central than consuming some random jars from jitpack)

@jmartisk jmartisk reopened this Jan 2, 2025
@jmartisk
Copy link
Contributor

jmartisk commented Jan 2, 2025

Then let's have another look, we may be wrongly registering the synthetic bean for the client API... @mskacelik maybe you have some time for this?

@jmini As for the tests that you asked, I assume we would simply dynamically build a JAR using ShrinkWrap and add it into the deployment (most tests just build the testing artifact via ShrinkWrap, this one would build two artifacts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql area/jbang Issues related to when using jbang.dev with Quarkus area/smallrye
Projects
None yet
4 participants