use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFetchErrorOrAbsentWithoutPath.
@Test
void shouldFetchErrorOrAbsentWithoutPath() {
fixture.returns("{" + "\"data\":{\"teams\":null}," + "\"errors\":[{" + /**/
"\"message\":\"currently can't search for teams\"," + /**/
"\"locations\":[{\"line\":1,\"column\":2,\"sourceName\":\"loc\"}]," + /**/
"\"extensions\":{" + /**/
"\"description\":\"Field 'foo' in type 'Query' is undefined\"," + /**/
"\"validationErrorType\":\"FieldUndefined\"," + /**/
"\"queryPath\":[\"foo\"]," + /**/
"\"classification\":\"ValidationError\"," + /**/
"\"code\":\"team-search-disabled\"}" + "}]}}");
SuperHeroApi api = fixture.build(SuperHeroApi.class);
GraphQLClientException throwable = catchThrowableOfType(api::teams, GraphQLClientException.class);
then(fixture.query()).isEqualTo("query teams { teams {name} }");
then(throwable).hasExactlyOneErrorWhich().hasMessage("currently can't search for teams").hasNoPath().hasSourceLocation(1, 2).hasErrorCode("team-search-disabled");
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailToMapInnerNestedError.
@Test
void shouldFailToMapInnerNestedError() {
fixture.returns(deeplyNestedError("{\"outer\":{\"inner\":null}}"));
DeepErrorApi api = fixture.build(DeepErrorApi.class);
GraphQLClientException throwable = catchThrowableOfType(api::outer, GraphQLClientException.class);
thenDeeplyNestedErrorException(throwable);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class DynamicClientErrorTest method convertToGraphQLClientException.
/**
* Test the `ResponseImpl.throwExceptionIfErrors` method that should throw a `GraphQLClientException` if the Response
* contains any errors.
*/
@Test
public void convertToGraphQLClientException() throws ExecutionException, InterruptedException {
Response response = client.executeSync(document(operation(field("dummy", field("foo"), field("bar")))));
try {
((ResponseImpl) response).throwExceptionIfErrors();
fail("`throwExceptionIfErrors` call should throw a GraphQLClientException");
} catch (GraphQLClientException e) {
assertArrayEquals(new Object[] { "dummy", "bar" }, e.getErrors().get(0).getPath());
}
}
Aggregations