diff --git a/extensions/smallrye-graphql-client/deployment/src/main/java/io/quarkus/smallrye/graphql/client/deployment/SmallRyeGraphQLClientProcessor.java b/extensions/smallrye-graphql-client/deployment/src/main/java/io/quarkus/smallrye/graphql/client/deployment/SmallRyeGraphQLClientProcessor.java index 7bfd1f68aea4c..f61dcbbf2d5d9 100644 --- a/extensions/smallrye-graphql-client/deployment/src/main/java/io/quarkus/smallrye/graphql/client/deployment/SmallRyeGraphQLClientProcessor.java +++ b/extensions/smallrye-graphql-client/deployment/src/main/java/io/quarkus/smallrye/graphql/client/deployment/SmallRyeGraphQLClientProcessor.java @@ -12,6 +12,7 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Singleton; +import org.eclipse.microprofile.graphql.Input; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.ClassInfo; @@ -236,6 +237,7 @@ void setAdditionalClassesToIndex(BuildProducer jar - .addClasses(TestingGraphQLApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, Person.class, PersonDto.class) .addAsResource(new StringAsset("people-client/mp-graphql/url=" + url + "\n" + "people-client/mp-graphql/header/My-Header=My-Value"), "application.properties") diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientInjectionWithQuarkusConfigTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientInjectionWithQuarkusConfigTest.java index 2bbc1133d4083..abf35039193ec 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientInjectionWithQuarkusConfigTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientInjectionWithQuarkusConfigTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.test.QuarkusUnitTest; import io.smallrye.graphql.client.GraphQLClient; @@ -32,7 +33,7 @@ public class DynamicGraphQLClientInjectionWithQuarkusConfigTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, Person.class, PersonDto.class) .addAsResource(new StringAsset("quarkus.smallrye-graphql-client.people.url=" + url + "\n" + "quarkus.smallrye-graphql-client.people.header.My-Header=My-Value"), "application.properties") diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientProgrammaticUsageTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientProgrammaticUsageTest.java index 908efe65ca79b..c6b9590ccd3cb 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientProgrammaticUsageTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientProgrammaticUsageTest.java @@ -13,6 +13,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.test.QuarkusUnitTest; import io.quarkus.test.common.http.TestHTTPResource; @@ -26,7 +27,7 @@ public class DynamicGraphQLClientProgrammaticUsageTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, Person.class, PersonDto.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); @TestHTTPResource diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/StorkAndGraphQLClientTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/StorkAndGraphQLClientTest.java index bde9d888ddaec..344599fa07e29 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/StorkAndGraphQLClientTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/StorkAndGraphQLClientTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; import io.quarkus.test.QuarkusUnitTest; @@ -21,7 +22,7 @@ public class StorkAndGraphQLClientTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) .addAsResource(new StringAsset( "quarkus.smallrye-graphql-client.typesafeclient.url=stork://foo-service/graphql\n" + "quarkus.stork.foo-service.service-discovery.type=static\n" + diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypeSafeGraphQLParameterInputNameWithClientModelTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypeSafeGraphQLParameterInputNameWithClientModelTest.java new file mode 100644 index 0000000000000..0f59d6016d20a --- /dev/null +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypeSafeGraphQLParameterInputNameWithClientModelTest.java @@ -0,0 +1,34 @@ +package io.quarkus.smallrye.graphql.client.deployment; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import jakarta.inject.Inject; + +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; +import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; +import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; +import io.quarkus.test.QuarkusUnitTest; + +public class TypeSafeGraphQLParameterInputNameWithClientModelTest { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); + + @Inject + TestingGraphQLClientApi client; + + @Test + public void performQuery() { + final String expectedName = "Mark"; + String actualPerson = client.getNameOfThePerson(new PersonDto(expectedName)); + assertEquals(expectedName, actualPerson); + } +} diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientFQNameTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientFQNameTest.java index d3b1033ce74e4..88c881bbc2ee4 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientFQNameTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientFQNameTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApiWithNoConfigKey; import io.quarkus.test.QuarkusUnitTest; @@ -27,7 +28,8 @@ public class TypesafeGraphQLClientFQNameTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApiWithNoConfigKey.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApiWithNoConfigKey.class, Person.class, + PersonDto.class) .addAsResource( new StringAsset( "quarkus.smallrye-graphql-client.\"io.quarkus.smallrye.graphql." + diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionTest.java index c75b3fb652109..07c8e796380d0 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; import io.quarkus.test.QuarkusUnitTest; @@ -24,7 +25,7 @@ public class TypesafeGraphQLClientInjectionTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) .addAsResource(new StringAsset("typesafeclient/mp-graphql/url=" + url + "\n" + "typesafeclient/mp-graphql/header/My-Header=My-Value"), "application.properties") diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionWithQuarkusConfigTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionWithQuarkusConfigTest.java index 1b066b01ab7ac..03d7197993851 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionWithQuarkusConfigTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientInjectionWithQuarkusConfigTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; import io.quarkus.test.QuarkusUnitTest; @@ -24,7 +25,7 @@ public class TypesafeGraphQLClientInjectionWithQuarkusConfigTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) .addAsResource(new StringAsset("quarkus.smallrye-graphql-client.typesafeclient.url=" + url + "\n" + "quarkus.smallrye-graphql-client.typesafeclient.header.My-Header=My-Value"), "application.properties") diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageTest.java index c06279e6eb031..b3fc7caa0bb13 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageTest.java @@ -10,6 +10,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; import io.quarkus.test.QuarkusUnitTest; @@ -21,7 +22,7 @@ public class TypesafeGraphQLClientProgrammaticUsageTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); @TestHTTPResource diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageWithClientModelTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageWithClientModelTest.java index ec091a6a82cad..768e5dafe143c 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageWithClientModelTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientProgrammaticUsageWithClientModelTest.java @@ -6,12 +6,14 @@ import java.net.URL; import java.util.List; +import org.eclipse.microprofile.graphql.Input; import org.jboss.jandex.Index; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi; import io.quarkus.test.QuarkusUnitTest; @@ -26,7 +28,7 @@ public class TypesafeGraphQLClientProgrammaticUsageWithClientModelTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); @TestHTTPResource @@ -34,7 +36,8 @@ public class TypesafeGraphQLClientProgrammaticUsageWithClientModelTest { @Test public void performQuery() throws IOException { - Index index = Index.of(GraphQLClientApi.class, TestingGraphQLClientApi.class, Person.class); + Index index = Index.of(GraphQLClientApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class, + Input.class); TestingGraphQLClientApi client = ((VertxTypesafeGraphQLClientBuilder) TypesafeGraphQLClientBuilder.newBuilder()) .clientModels(ClientModelBuilder.build(index)) .endpoint(url.toString() + "/graphql") diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientShortcutTest.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientShortcutTest.java index 84840596fe0a9..8e66221907ec9 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientShortcutTest.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/TypesafeGraphQLClientShortcutTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.smallrye.graphql.client.deployment.model.Person; +import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi; import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApiWithNoConfigKey; import io.quarkus.test.QuarkusUnitTest; @@ -28,7 +29,8 @@ public class TypesafeGraphQLClientShortcutTest { @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar - .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApiWithNoConfigKey.class, Person.class) + .addClasses(TestingGraphQLApi.class, TestingGraphQLClientApiWithNoConfigKey.class, Person.class, + PersonDto.class) .addAsResource( new StringAsset( "quarkus.smallrye-graphql-client.TestingGraphQLClientApiWithNoConfigKey.url=" + url), diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/PersonDto.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/PersonDto.java new file mode 100644 index 0000000000000..c0b6129225c29 --- /dev/null +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/PersonDto.java @@ -0,0 +1,23 @@ +package io.quarkus.smallrye.graphql.client.deployment.model; + +import org.eclipse.microprofile.graphql.Input; + +@Input("PersonInput") +public class PersonDto { + private String name; + + public PersonDto() { + } + + public PersonDto(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLApi.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLApi.java index f6f73aed7485e..df3b331195ded 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLApi.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLApi.java @@ -8,6 +8,7 @@ import org.eclipse.microprofile.graphql.Query; import io.quarkus.vertx.http.runtime.CurrentVertxRequest; +import io.smallrye.graphql.execution.context.SmallRyeContext; @GraphQLApi public class TestingGraphQLApi { @@ -15,6 +16,9 @@ public class TestingGraphQLApi { @Inject CurrentVertxRequest request; + @Inject + SmallRyeContext ctx; + @Query public List people() { Person person1 = new Person(); @@ -36,4 +40,14 @@ public String returnHeader(String key) { return request.getCurrent().request().getHeader(key); } + private final String EXPECTED_QUERY_FOR_NAME_OF_THE_PERSON = "query nameOfThePerson($personDto: PersonInput) { nameOfThePerson(personDto: $personDto) }"; + + @Query + public String getNameOfThePerson(PersonDto personDto) { + if (!ctx.getQuery().equals(EXPECTED_QUERY_FOR_NAME_OF_THE_PERSON)) + throw new RuntimeException( + String.format("Wrong Query - expected: %s\n actual: %s", EXPECTED_QUERY_FOR_NAME_OF_THE_PERSON, + ctx.getQuery())); + return personDto.getName(); + } } diff --git a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLClientApi.java b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLClientApi.java index f28ccc571feb6..e456c86bd6396 100644 --- a/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLClientApi.java +++ b/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/model/TestingGraphQLClientApi.java @@ -15,4 +15,7 @@ public interface TestingGraphQLClientApi { @Query public String returnHeader(String key); + @Query + public String getNameOfThePerson(PersonDto personDto); + }