Skip to content

Commit 83743e8

Browse files
authored
Merge pull request #31809 from mskacelik/smallrye-graphQL-2.1.2
Update SmallRye GraphQL to 2.1.2
2 parents 26013ff + d85e455 commit 83743e8

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

bom/application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<smallrye-health.version>4.0.1</smallrye-health.version>
6060
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
6161
<smallrye-open-api.version>3.3.0</smallrye-open-api.version>
62-
<smallrye-graphql.version>2.1.1</smallrye-graphql.version>
62+
<smallrye-graphql.version>2.1.2</smallrye-graphql.version>
6363
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
6464
<smallrye-fault-tolerance.version>6.2.1</smallrye-fault-tolerance.version>
6565
<smallrye-jwt.version>4.2.0</smallrye-jwt.version>

extensions/smallrye-graphql-client/deployment/src/main/java/io/quarkus/smallrye/graphql/client/deployment/SmallRyeGraphQLClientProcessor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@ void setupServiceProviders(BuildProducer<ServiceProviderBuildItem> services) {
6464
services.produce(ServiceProviderBuildItem
6565
.allProvidersFromClassPath("io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder"));
6666
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Argument"));
67+
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Directive"));
68+
services.produce(
69+
ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.DirectiveArgument"));
6770
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Document"));
6871
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Enum"));
6972
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Field"));
73+
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.Fragment"));
74+
services.produce(
75+
ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.FragmentReference"));
76+
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.InlineFragment"));
7077
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.InputObject"));
7178
services.produce(
7279
ServiceProviderBuildItem.allProvidersFromClassPath("io.smallrye.graphql.client.core.InputObjectField"));

integration-tests/smallrye-graphql-client/src/main/java/io/quarkus/io/smallrye/graphql/client/GraphQLClientTester.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import static io.smallrye.graphql.client.core.Argument.arg;
44
import static io.smallrye.graphql.client.core.Argument.args;
5+
import static io.smallrye.graphql.client.core.Directive.directive;
6+
import static io.smallrye.graphql.client.core.DirectiveArgument.directiveArg;
57
import static io.smallrye.graphql.client.core.Document.document;
68
import static io.smallrye.graphql.client.core.Field.field;
9+
import static io.smallrye.graphql.client.core.Field.fieldWithDirectives;
710
import static io.smallrye.graphql.client.core.Operation.operation;
811

912
import java.util.List;
@@ -151,6 +154,24 @@ public void dynamicSubscription(@PathParam("url") String url) throws Exception {
151154
}
152155
}
153156

157+
@GET
158+
@Path("/dynamic-directive/{url}")
159+
public void dynamicDirective(@PathParam("url") String url) throws Exception {
160+
try (DynamicGraphQLClient client = DynamicGraphQLClientBuilder.newBuilder().url(url.toString() + "/graphql").build()) {
161+
Document query = document(
162+
operation(OperationType.QUERY,
163+
fieldWithDirectives("piNumber",
164+
directive("skip", directiveArg("if", false)))));
165+
Response response = client.executeSync(query);
166+
167+
final String expectedResult = "3.14159";
168+
final String result = response.getData().getString("piNumber");
169+
if (!result.equals(expectedResult)) {
170+
throw new RuntimeException("Unexpected response: " + response);
171+
}
172+
}
173+
}
174+
154175
@GraphQLClient("some-key")
155176
Instance<DynamicGraphQLClient> autowiredDynamicClient;
156177

integration-tests/smallrye-graphql-client/src/main/java/io/quarkus/io/smallrye/graphql/client/LuckyNumbersResource.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import org.eclipse.microprofile.graphql.NonNull;
1010
import org.eclipse.microprofile.graphql.Query;
1111

12+
import graphql.execution.directives.QueryDirectives;
1213
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
1314
import io.smallrye.graphql.api.Subscription;
15+
import io.smallrye.graphql.execution.context.SmallRyeContext;
1416
import io.smallrye.mutiny.Multi;
1517

1618
@GraphQLApi
@@ -21,6 +23,9 @@ public class LuckyNumbersResource {
2123
@Inject
2224
CurrentVertxRequest request;
2325

26+
@Inject
27+
SmallRyeContext context;
28+
2429
@Query(value = "get")
2530
public Integer luckyNumber() {
2631
return luckyNumber;
@@ -47,4 +52,14 @@ public String returnHeader(String key) {
4752
return request.getCurrent().request().getHeader(key);
4853
}
4954

55+
@Query
56+
public String piNumber() {
57+
QueryDirectives directives = context.getDataFetchingEnvironment().getQueryDirectives();
58+
if (directives.getImmediateAppliedDirective("skip").isEmpty()) {
59+
throw new IllegalArgumentException("Directive 'skip' was not found in the query (on the server side).");
60+
}
61+
62+
return "3.14159";
63+
}
64+
5065
}

integration-tests/smallrye-graphql-client/src/test/java/io/quarkus/it/smallrye/graphql/client/DynamicClientTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ public void testDynamicClientAutowiredUrl() throws Exception {
5656
.statusCode(204);
5757
}
5858

59+
@Test
60+
public void testDynamicClientDirective() throws Exception {
61+
when()
62+
.get("/dynamic-directive/" + url.toString())
63+
.then()
64+
.log().everything()
65+
.statusCode(204);
66+
}
67+
5968
}

0 commit comments

Comments
 (0)