Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<smallrye-health.version>4.3.0</smallrye-health.version>
<smallrye-modules.version>1.0.beta1</smallrye-modules.version>
<smallrye-open-api.version>4.3.3</smallrye-open-api.version>
<smallrye-graphql.version>3.0.0.Beta3</smallrye-graphql.version>
<smallrye-graphql.version>3.0.0.Beta4-SNAPSHOT</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.11.2</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.6.3</smallrye-jwt.version>
<smallrye-context-propagation.version>2.3.0</smallrye-context-propagation.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String getAccessToken() {
@GET
@Path("/default-dynamic")
public String dynamicClientDefault() throws ExecutionException, InterruptedException {
return dynamicClient.executeSync("query { principalName }").getData().getString("principalName");
return dynamicClient.executeSync("query { principalName }").getData().get("principalName").asText();
}

@Inject
Expand All @@ -53,7 +53,7 @@ public String dynamicClientDefault() throws ExecutionException, InterruptedExcep
@GET
@Path("/jdoe-dynamic")
public String dynamicClientJDoe() throws ExecutionException, InterruptedException {
return jDoeDynamicClient.executeSync("query { principalName }").getData().getString("principalName");
return jDoeDynamicClient.executeSync("query { principalName }").getData().get("principalName").asText();
}

@Inject
Expand All @@ -63,7 +63,7 @@ public String dynamicClientJDoe() throws ExecutionException, InterruptedExceptio
@GET
@Path("/admin-dynamic")
public String dynamicClientAdmin() throws ExecutionException, InterruptedException {
return adminDynamicClient.executeSync("query { principalName }").getData().getString("principalName");
return adminDynamicClient.executeSync("query { principalName }").getData().get("principalName").asText();
}

}
2 changes: 1 addition & 1 deletion extensions/smallrye-graphql-client/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb-deployment</artifactId>
<artifactId>quarkus-jackson-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void checkInjectedClient() {
public void checkHeaders() throws ExecutionException, InterruptedException {
Document query = document(
Operation.operation(field("returnHeader", arg("key", "My-Header"))));
String header = client.executeSync(query).getData().getString("returnHeader");
String header = client.executeSync(query).getData().get("returnHeader").asText();
assertEquals("My-Value", header);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void checkInjectedClient() {
public void checkHeaders() throws ExecutionException, InterruptedException {
Document query = document(
Operation.operation(field("returnHeader", arg("key", "My-Header"))));
String header = client.executeSync(query).getData().getString("returnHeader");
String header = client.executeSync(query).getData().get("returnHeader").asText();
assertEquals("My-Value", header);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.stream.Stream;

import jakarta.annotation.security.RolesAllowed;
import jakarta.json.JsonValue;

import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
Expand Down Expand Up @@ -72,13 +71,13 @@ public void testAuthenticatedUserForQueryWebSocketOverInitParams(String subproto
for (int i = 0; i < 3; i++) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals("foo", response.getData().getJsonObject("foo").getString("message"));
assertEquals("foo", response.getData().get("foo").get("message").asText());
}

// Unauthorized query
Response response = client.executeSync("{ bar { message} }");
assertTrue(response.hasData());
assertEquals(JsonValue.ValueType.NULL, response.getData().get("bar").getValueType());
assertTrue(response.getData().get("bar").isNull());
}
}

Expand All @@ -93,7 +92,7 @@ public void testUnauthenticatedUserForQueryWebSocketOverInitParams(String subpro
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals(JsonValue.ValueType.NULL, response.getData().get("foo").getValueType());
assertTrue(response.getData().get("foo").isNull());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.concurrent.atomic.AtomicBoolean;

import jakarta.annotation.security.RolesAllowed;
import jakarta.json.JsonValue;

import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
Expand Down Expand Up @@ -65,8 +64,8 @@ public void testAuthenticatedUserForSubscription() throws Exception {
subscription.subscribe().with(item -> {
assertFalse(hasData.get());
assertTrue(item.hasData());
assertEquals(JsonValue.ValueType.OBJECT, item.getData().get("fooSub").getValueType());
assertEquals("foo", item.getData().getJsonObject("fooSub").getString("message"));
assertTrue(item.getData().get("fooSub").isObject());
assertEquals("foo", item.getData().get("fooSub").get("message").asText());
hasData.set(true);
}, Assertions::fail, () -> {
hasCompleted.set(true);
Expand All @@ -86,7 +85,7 @@ public void testAuthenticatedUserForQueryWebSocket() throws Exception {
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals("foo", response.getData().getJsonObject("foo").getString("message"));
assertEquals("foo", response.getData().get("foo").get("message").asText());
}
}

Expand All @@ -99,11 +98,11 @@ public void testAuthorizedAndUnauthorizedForQueryWebSocket() throws Exception {
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals("foo", response.getData().getJsonObject("foo").getString("message"));
assertEquals("foo", response.getData().get("foo").get("message").asText());

// Run a second query with a different result to validate that the result of the first query isn't being cached at all.
response = client.executeSync("{ bar { message} }");
assertEquals(JsonValue.ValueType.NULL, response.getData().get("bar").getValueType());
assertTrue(response.getData().get("bar").isNull());
}
}

Expand All @@ -121,7 +120,7 @@ public void testUnauthorizedUserForSubscription() throws Exception {
AtomicBoolean returned = new AtomicBoolean(false);

subscription.subscribe().with(item -> {
assertEquals(JsonValue.ValueType.NULL, item.getData().get("barSub").getValueType());
assertTrue(item.getData().get("barSub").isNull());
returned.set(true);
}, throwable -> Assertions.fail(throwable));

Expand All @@ -138,7 +137,7 @@ public void testAuthenticatedUserButDefinedWithClientInitForQueryWebSocket() thr
.executeSingleOperationsOverWebsocket(true);
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertEquals(JsonValue.ValueType.NULL, response.getData().get("foo").getValueType());
assertTrue(response.getData().get("foo").isNull());
}
}

Expand All @@ -150,7 +149,7 @@ public void testUnauthorizedUserForQueryWebSocket() throws Exception {
.executeSingleOperationsOverWebsocket(true);
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ bar { message } }");
assertEquals(JsonValue.ValueType.NULL, response.getData().get("bar").getValueType());
assertTrue(response.getData().get("bar").isNull());
}
}

Expand All @@ -161,7 +160,7 @@ public void testUnauthenticatedForQueryWebSocket() throws Exception {
.executeSingleOperationsOverWebsocket(true);
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertEquals(JsonValue.ValueType.NULL, response.getData().get("foo").getValueType());
assertTrue(response.getData().get("foo").isNull());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void testReloading() throws IOException, ExecutionException, InterruptedExceptio
event.fire(new CertificateUpdatedEvent("my-tls-client", tlsClient));

Response response = client.executeSync("{ result }");
assertThat(response.getData().getString("result")).isEqualTo(EXPECTED_RESPONSE);
assertThat(response.getData().get("result").asText()).isEqualTo(EXPECTED_RESPONSE);
}

@AfterAll
Expand Down
8 changes: 1 addition & 7 deletions extensions/smallrye-graphql-client/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
<artifactId>quarkus-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -49,12 +49,6 @@
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-implementation-vertx</artifactId>
<exclusions>
<exclusion>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
8 changes: 6 additions & 2 deletions extensions/smallrye-graphql/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb-deployment</artifactId>
<artifactId>quarkus-jackson-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonp-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-schema-builder</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
import io.smallrye.graphql.schema.model.Field;
import io.smallrye.graphql.schema.model.InputType;
import io.smallrye.graphql.schema.model.Operation;
import io.smallrye.graphql.schema.model.ParametrizedTypeEntry;
import io.smallrye.graphql.schema.model.Reference;
import io.smallrye.graphql.schema.model.ReferenceType;
import io.smallrye.graphql.schema.model.Scalars;
Expand Down Expand Up @@ -974,10 +975,6 @@ void buildExecutionEndpoint(
private Set<String> getAllAdapterClasses(IndexView index) {
Set<String> adapterClasses = new HashSet<>();
adapterClasses.addAll(getAdapterClasses(index, DotName.createSimple(AdaptWith.class.getName())));
adapterClasses.addAll(
getAdapterClasses(index, DotName.createSimple("jakarta.json.bind.annotation.JsonbTypeAdapter")));
adapterClasses.addAll(
getAdapterClasses(index, DotName.createSimple("jakarta.json.bind.annotation.JsonbTypeAdapter")));
return adapterClasses;
}

Expand Down Expand Up @@ -1106,11 +1103,9 @@ private Set<String> getFieldClassNames(Map<String, Field> fields) {
private Set<String> getAllReferenceClasses(Reference reference) {
Set<String> classes = new HashSet<>();
classes.add(reference.getClassName());
if (reference.getClassParametrizedTypes() != null && !reference.getClassParametrizedTypes().isEmpty()) {

Collection<Reference> parametrized = reference.getClassParametrizedTypes().values();
for (Reference r : parametrized) {
classes.addAll(getAllReferenceClasses(r));
if (reference.hasParametrizedTypes()) {
for (ParametrizedTypeEntry entry : reference.getParametrizedTypes().values()) {
classes.addAll(getAllReferenceClasses(entry.getReference()));
}
}
return classes;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package io.quarkus.smallrye.graphql.deployment;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;

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 com.fasterxml.jackson.databind.node.ObjectNode;

import io.quarkus.test.QuarkusExtensionTest;
import io.restassured.RestAssured;

/**
* Support for the JSON graphql type represented in Java as Jackson ObjectNode
*/
public class ObjectNodeScalarTest extends AbstractGraphQLTest {

@RegisterExtension
static QuarkusExtensionTest test = new QuarkusExtensionTest()
.withApplicationRoot((jar) -> jar
.addClasses(ObjectNodeApi.class)
.addAsResource(new StringAsset("quarkus.smallrye-graphql.extra-scalars=json\n" +
"quarkus.smallrye-graphql.schema-include-scalars=true"),
"application.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));

@Test
public void testObjectNode() {
String query = getPayload("{ echo(input: { field1: 1, field2: \"2\"}) }");
RestAssured.given()
.body(query)
.contentType(MEDIATYPE_JSON)
.post("/graphql/")
.then()
.assertThat()
.statusCode(200)
.body("data.echo.field1", equalTo(1))
.body("data.echo.field2", equalTo("2"));
}

@Test
public void testObjectNodeSchemaDefinition() {
RestAssured.given()
.get("/graphql/schema.graphql")
.prettyPeek()
.then()
.assertThat()
.body(containsString("scalar JSON"))
.body(containsString("echo(input: JSON): JSON"))
.statusCode(200);
}

@GraphQLApi
public static class ObjectNodeApi {

@Query
public ObjectNode echo(ObjectNode input) {
return input;
}

}

}
6 changes: 5 additions & 1 deletion extensions/smallrye-graphql/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
<artifactId>quarkus-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonp</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
Expand Down
19 changes: 19 additions & 0 deletions integration-tests/hibernate-orm-graphql-panache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<!-- FIXME: Hibernate's JakartaJsonIntegration fails in native mode if JSON-B api is present, but no implementation is available.
SmallRye GraphQL adds just the API to classpath. What to do? Fix it in Hibernate? -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit</artifactId>
Expand Down Expand Up @@ -101,6 +107,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
Loading
Loading