Search in sources :

Example 1 with ResponseReader

use of io.smallrye.graphql.client.impl.ResponseReader in project smallrye-graphql by smallrye.

the class ResultBuilder method readErrors.

private void readErrors() {
    if (!response.containsKey("errors") || response.isNull("errors"))
        return;
    JsonArray jsonErrors = response.getJsonArray("errors");
    if (jsonErrors == null)
        return;
    JsonArray unapplied = jsonErrors.stream().filter(error -> !apply(error)).collect(toJsonArray());
    if (unapplied.isEmpty())
        return;
    throw new GraphQLClientException("errors from service", unapplied.stream().map(ResponseReader::readError).collect(Collectors.toList()));
}
Also used : JsonCollectors.toJsonArray(javax.json.stream.JsonCollectors.toJsonArray) JsonArray(javax.json.JsonArray) JsonCollectors.toJsonArray(javax.json.stream.JsonCollectors.toJsonArray) JsonObject(javax.json.JsonObject) JsonArrayBuilder(javax.json.JsonArrayBuilder) JsonReader(io.smallrye.graphql.client.impl.typesafe.json.JsonReader) JsonPatch(javax.json.JsonPatch) GraphQLClientException(io.smallrye.graphql.client.GraphQLClientException) JsonArray(javax.json.JsonArray) ErrorOr(io.smallrye.graphql.client.typesafe.api.ErrorOr) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) JsonValue(javax.json.JsonValue) ResponseReader(io.smallrye.graphql.client.impl.ResponseReader) List(java.util.List) StringReader(java.io.StringReader) JsonUtils.isListOf(io.smallrye.graphql.client.impl.typesafe.json.JsonUtils.isListOf) JsonUtils(io.smallrye.graphql.client.impl.typesafe.json.JsonUtils) JsonException(javax.json.JsonException) Json(javax.json.Json) MethodInvocation(io.smallrye.graphql.client.impl.typesafe.reflection.MethodInvocation) JsonPointer(javax.json.JsonPointer) InvalidResponseException(io.smallrye.graphql.client.InvalidResponseException) GraphQLClientException(io.smallrye.graphql.client.GraphQLClientException) ResponseReader(io.smallrye.graphql.client.impl.ResponseReader)

Aggregations

GraphQLClientException (io.smallrye.graphql.client.GraphQLClientException)1 InvalidResponseException (io.smallrye.graphql.client.InvalidResponseException)1 ResponseReader (io.smallrye.graphql.client.impl.ResponseReader)1 JsonReader (io.smallrye.graphql.client.impl.typesafe.json.JsonReader)1 JsonUtils (io.smallrye.graphql.client.impl.typesafe.json.JsonUtils)1 JsonUtils.isListOf (io.smallrye.graphql.client.impl.typesafe.json.JsonUtils.isListOf)1 MethodInvocation (io.smallrye.graphql.client.impl.typesafe.reflection.MethodInvocation)1 ErrorOr (io.smallrye.graphql.client.typesafe.api.ErrorOr)1 StringReader (java.io.StringReader)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Collectors.joining (java.util.stream.Collectors.joining)1 Json (javax.json.Json)1 JsonArray (javax.json.JsonArray)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonException (javax.json.JsonException)1 JsonObject (javax.json.JsonObject)1 JsonPatch (javax.json.JsonPatch)1 JsonPointer (javax.json.JsonPointer)1 JsonValue (javax.json.JsonValue)1