use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnQueryError.
@Test
void shouldFailOnQueryError() {
fixture.returns("{" + "\"data\":{\"greeting\":null}," + "\"errors\":[{" + /**/
"\"message\":\"currently can't greet\"," + /**/
"\"locations\":[{\"line\":1,\"column\":2}]," + /**/
"\"path\": [\"greeting\"],\n" + /**/
"\"extensions\":{" + /**/
"\"description\":\"some description\"," + /**/
"\"queryPath\":[\"greeting\"]," + /**/
"\"classification\":\"DataFetchingException\"," + /**/
"\"code\":\"no-greeting\"}" + "}]}}");
StringApi api = fixture.build(StringApi.class);
GraphQLClientException thrown = catchThrowableOfType(api::greeting, GraphQLClientException.class);
then(thrown).hasExactlyOneErrorWhich().hasMessage("currently can't greet").hasSourceLocation(1, 2).hasPath("greeting").hasErrorCode("no-greeting");
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class GraphQLTransportWSSubprotocolHandler method handleOperationError.
private void handleOperationError(String operationId, JsonArray errors) {
List<GraphQLError> parsedErrors = errors.stream().map(ResponseReader::readError).collect(Collectors.toList());
GraphQLClientException exception = new GraphQLClientException("Received an error", parsedErrors);
UniEmitter<? super String> emitter = uniOperations.remove(operationId);
if (emitter != null) {
emitter.fail(exception);
} else {
MultiEmitter<? super String> multiEmitter = multiOperations.remove(operationId);
if (multiEmitter != null) {
multiEmitter.fail(exception);
}
}
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class GraphQLWSSubprotocolHandler method handleOperationError.
private void handleOperationError(String operationId, JsonObject error) {
GraphQLError parsedError = ResponseReader.readError(error);
GraphQLClientException exception = new GraphQLClientException("Received an error", parsedError);
UniEmitter<? super String> emitter = uniOperations.remove(operationId);
if (emitter != null) {
emitter.fail(exception);
} else {
MultiEmitter<? super String> multiEmitter = multiOperations.remove(operationId);
if (multiEmitter != null) {
multiEmitter.fail(exception);
}
}
}
use of io.smallrye.graphql.client.GraphQLClientException 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()));
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailToMapDirectNestedError.
@Test
void shouldFailToMapDirectNestedError() {
fixture.returns(deeplyNestedError("null"));
DeepErrorApi api = fixture.build(DeepErrorApi.class);
GraphQLClientException throwable = catchThrowableOfType(api::outer, GraphQLClientException.class);
thenDeeplyNestedErrorException(throwable);
}
Aggregations