From bd5873b85ceadc2dd8f2a037b52830601406e6a1 Mon Sep 17 00:00:00 2001 From: Marek Skacelik Date: Tue, 14 Feb 2023 13:31:51 +0100 Subject: [PATCH] SmallRye GraphQL 1.9.3, test for Deprecated annotation --- bom/application/pom.xml | 2 +- .../deployment/SmallRyeGraphQLProcessor.java | 2 + .../DeprecatedGraphQLDirectivesTest.java | 90 +++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/DeprecatedGraphQLDirectivesTest.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 1c8d247a97672..8cb0280e54bb3 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -47,7 +47,7 @@ 3.3.1 3.0.5 3.1.1 - 1.9.1 + 1.9.3 2.1.1 5.6.0 3.6.0 diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index 3e8ae58571990..ad7da89e379df 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -70,6 +70,7 @@ import io.quarkus.vertx.http.deployment.webjar.WebJarResourcesFilter; import io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem; import io.smallrye.graphql.api.AdaptWith; +import io.smallrye.graphql.api.Deprecated; import io.smallrye.graphql.api.Entry; import io.smallrye.graphql.api.ErrorExtensionProvider; import io.smallrye.graphql.api.federation.Extends; @@ -255,6 +256,7 @@ void buildFinalIndex( indexer.indexClass(Key.class); indexer.indexClass(Provides.class); indexer.indexClass(Requires.class); + indexer.indexClass(Deprecated.class); } catch (IOException ex) { LOG.warn("Failure while creating index", ex); } diff --git a/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/DeprecatedGraphQLDirectivesTest.java b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/DeprecatedGraphQLDirectivesTest.java new file mode 100644 index 0000000000000..311e2fbe869c8 --- /dev/null +++ b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/DeprecatedGraphQLDirectivesTest.java @@ -0,0 +1,90 @@ +package io.quarkus.smallrye.graphql.deployment; + +import static io.restassured.RestAssured.get; +import static org.hamcrest.Matchers.containsString; + +import org.eclipse.microprofile.graphql.GraphQLApi; +import org.eclipse.microprofile.graphql.Query; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.smallrye.graphql.api.Deprecated; + +public class DeprecatedGraphQLDirectivesTest extends AbstractGraphQLTest { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(Person.class) + .addAsResource(new StringAsset("quarkus.smallrye-graphql.schema-include-directives=true"), + "application.properties") + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); + + @Test + public void deprecatedDirectivesPresentInSchema() { + get("/graphql/schema.graphql") + .then() + .body(containsString("input PersonInput {\n" + + " age: Int! @deprecated\n" + + " name: String @deprecated(reason : \"reason0\")\n" + + " numberOfEyes: BigInteger! @deprecated\n" + + "}\n")) + .body(containsString( + "queryWithDeprecatedArgument(deprecated: String @deprecated(reason : \"reason1\")): String")); + } + + @GraphQLApi + public static class ValidationApi { + + @Query + public String query(Person person) { + return null; + } + + @Query + public String queryWithDeprecatedArgument(@Deprecated(reason = "reason1") String deprecated) { + return null; + } + + } + + public static class Person { + + @Deprecated(reason = "reason0") + private String name; + + @java.lang.Deprecated + private int age; + + @Deprecated + private long numberOfEyes; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public long getNumberOfEyes() { + return numberOfEyes; + } + + public void setNumberOfEyes(long numberOfEyes) { + this.numberOfEyes = numberOfEyes; + } + } + +}