Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Map;

import com.fasterxml.jackson.databind.node.ObjectNode;
import tools.jackson.databind.node.ObjectNode;

public interface Request {
String getDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.node.ObjectNode;
import tools.jackson.databind.node.ObjectNode;

public interface Response {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import java.util.Map;
import java.util.Objects;

import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.GraphQLError;
import tools.jackson.databind.node.ObjectNode;

public final class TypesafeResponse<T> extends ErrorOr<T> {
private Map<String, List<String>> transportMeta;
Expand Down
6 changes: 1 addition & 5 deletions client/implementation-vertx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@
<artifactId>microprofile-config-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-jackson-jsonb-compat</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.Request;
import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.core.Document;
Expand All @@ -41,6 +39,7 @@
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import tools.jackson.databind.node.ObjectNode;

public class VertxDynamicGraphQLClient implements DynamicGraphQLClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.InvalidResponseException;
import io.smallrye.graphql.client.impl.RequestImpl;
import io.smallrye.graphql.client.impl.discovery.ServiceURLSupplier;
Expand All @@ -55,6 +49,11 @@
import io.vertx.core.http.WebSocketConnectOptions;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.JsonNodeFactory;
import tools.jackson.databind.node.ObjectNode;

class VertxTypesafeGraphQLClientProxy {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package io.smallrye.graphql.client.vertx.websocket;

import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.subscription.MultiEmitter;
import io.smallrye.mutiny.subscription.UniEmitter;
import tools.jackson.databind.node.ObjectNode;

/**
* An implementation of this interface is responsible for handling a particular subscription websocket protocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.GraphQLClientException;
import io.smallrye.graphql.client.GraphQLError;
import io.smallrye.graphql.client.InvalidResponseException;
Expand All @@ -30,6 +24,11 @@
import io.smallrye.mutiny.subscription.MultiEmitter;
import io.smallrye.mutiny.subscription.UniEmitter;
import io.vertx.core.http.WebSocket;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.ObjectNode;

/**
* Implementation of the `graphql-transport-ws` protocol. The protocol specification is at
Expand Down Expand Up @@ -302,7 +301,7 @@ private MessageType getMessageType(ObjectNode message) {
private ObjectNode parseIncomingMessage(String message) {
try {
return (ObjectNode) MAPPER.readTree(message);
} catch (JsonProcessingException e) {
} catch (JacksonException e) {
throw new IllegalArgumentException("Failed to parse incoming message", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.GraphQLClientException;
import io.smallrye.graphql.client.GraphQLError;
import io.smallrye.graphql.client.InvalidResponseException;
Expand All @@ -27,6 +22,10 @@
import io.smallrye.mutiny.subscription.MultiEmitter;
import io.smallrye.mutiny.subscription.UniEmitter;
import io.vertx.core.http.WebSocket;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.node.ObjectNode;

/**
* Handler for the legacy `graphql-ws` subprotocol
Expand Down Expand Up @@ -210,7 +209,7 @@ public void close() {
private ObjectNode parseIncomingMessage(String message) {
try {
return (ObjectNode) MAPPER.readTree(message);
} catch (JsonProcessingException e) {
} catch (JacksonException e) {
throw new IllegalArgumentException("Failed to parse incoming message", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.InvalidResponseException;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import tools.jackson.databind.node.ObjectNode;

/**
* Make sure than when executing a sync operation with a dynamic client and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;
import io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientBuilder;
import io.vertx.core.MultiMap;
Expand All @@ -25,6 +22,8 @@
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import tck.graphql.typesafe.TypesafeGraphQLClientFixture;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.json.JsonMapper;

public class VertxTypesafeGraphQLClientFixture implements TypesafeGraphQLClientFixture {
private final WebClient mockWebClient = Mockito.mock(WebClient.class);
Expand Down Expand Up @@ -141,7 +140,7 @@ private JsonNode requestSent() {
then(mockHttpRequest).should().sendBuffer(captor.capture());
String requestString = captor.getValue().toString();
try {
requestSent = new ObjectMapper().readTree(requestString);
requestSent = JsonMapper.builder().build().readTree(requestString);
} catch (Exception e) {
throw new RuntimeException("Failed to parse request JSON", e);
}
Expand Down
10 changes: 1 addition & 9 deletions client/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-jackson-jsonb-compat</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
import java.util.Map;
import java.util.Objects;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.Request;
import io.smallrye.graphql.jackson.jsonb.JsonbCompatModule;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.node.ObjectNode;

public class RequestImpl implements Request {
public static final ObjectMapper MAPPER = JsonMapper.builder()
.addModule(new JsonbCompatModule())
.enable(com.fasterxml.jackson.databind.DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
.disable(com.fasterxml.jackson.databind.cfg.JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES)
.enable(tools.jackson.databind.DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
.disable(tools.jackson.databind.cfg.JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES)
.build();

private final String document;
Expand Down Expand Up @@ -78,7 +77,7 @@ public RequestImpl build() {
public String toJson() {
try {
return MAPPER.writeValueAsString(toJsonObject());
} catch (JsonProcessingException e) {
} catch (JacksonException e) {
throw new RuntimeException("Failed to serialize request to JSON", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import java.util.Map;
import java.util.Set;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.GraphQLClientException;
import io.smallrye.graphql.client.GraphQLError;
import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.impl.typesafe.json.JsonReader;
import io.smallrye.graphql.client.impl.typesafe.reflection.TypeInfo;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.ObjectNode;

public class ResponseImpl implements Response {

Expand Down Expand Up @@ -144,7 +143,7 @@ private Object getScalarValue(JsonNode value) {
*/
private static Set<String> fieldNames(ObjectNode node) {
Set<String> names = new LinkedHashSet<>();
node.fieldNames().forEachRemaining(names::add);
node.propertyNames().forEach(names::add);
return names;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.smallrye.graphql.client.GraphQLError;
import io.smallrye.graphql.client.InvalidResponseException;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.ObjectNode;

public class ResponseReader {
private static final Logger LOG = Logger.getLogger(ResponseReader.class.getName());
Expand Down Expand Up @@ -50,16 +49,14 @@ public static ObjectNode parseGraphQLResponse(String input, Boolean allowUnexpec
} else {
return null;
}
} catch (JsonProcessingException e) {
} catch (JacksonException e) {
return null;
}
}

private static ObjectNode checkExpectedResponseFields(ObjectNode jsonResponse,
Boolean allowUnexpectedResponseFields) {
var fieldNames = jsonResponse.fieldNames();
while (fieldNames.hasNext()) {
String key = fieldNames.next();
for (String key : jsonResponse.propertyNames()) {
if (!key.equalsIgnoreCase("data")
&& !key.equalsIgnoreCase("errors")
&& !key.equalsIgnoreCase("extensions")) {
Expand Down Expand Up @@ -143,7 +140,7 @@ public static GraphQLError readError(JsonNode errorJson) {
for (JsonNode jsonValue : locations) {
ObjectNode location = (ObjectNode) jsonValue;
Map<String, Integer> map = new HashMap<>();
location.fields().forEachRemaining(entry -> {
location.properties().forEach(entry -> {
// TODO: how to handle non-numeric location segments?
if (entry.getValue().isNumber()) {
map.put(entry.getKey(), entry.getValue().intValue());
Expand Down Expand Up @@ -187,7 +184,7 @@ public static GraphQLError readError(JsonNode errorJson) {
&& errorObject.get("extensions").isObject()) {
ObjectNode extensions = (ObjectNode) errorObject.get("extensions");
Map<String, Object> extensionMap = new HashMap<>();
extensions.fields().forEachRemaining(entry -> {
extensions.properties().forEach(entry -> {
extensionMap.put(entry.getKey(), decode(entry.getValue()));
});
decodedError.setExtensions(extensionMap);
Expand All @@ -201,7 +198,7 @@ public static GraphQLError readError(JsonNode errorJson) {
try {
// check if there are any other fields beyond the ones described by the specification
Map<String, Object> otherFields = new HashMap<>();
errorObject.fieldNames().forEachRemaining(key -> {
errorObject.propertyNames().forEach(key -> {
if (!key.equals("extensions") &&
!key.equals("locations") &&
!key.equals("message") &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

import com.fasterxml.jackson.databind.node.JsonNodeType;
import tools.jackson.databind.node.JsonNodeType;

@MessageLogger(projectCode = "SRGQL")
public interface SmallRyeGraphQLClientLogging {
Expand Down
Loading
Loading