Skip to content

Commit

Permalink
SmallRye GraphQL 1.9.3, test for Deprecated annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
mskacelik authored and jmartisk committed Feb 27, 2023
1 parent 62c22c1 commit 0b936a3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<smallrye-health.version>3.3.1</smallrye-health.version>
<smallrye-metrics.version>3.0.5</smallrye-metrics.version>
<smallrye-open-api.version>3.1.1</smallrye-open-api.version>
<smallrye-graphql.version>1.9.1</smallrye-graphql.version>
<smallrye-graphql.version>1.9.3</smallrye-graphql.version>
<smallrye-opentracing.version>2.1.1</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>5.6.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>3.6.0</smallrye-jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

}

0 comments on commit 0b936a3

Please sign in to comment.