use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFetchComplexError.
@Test
void shouldFetchComplexError() {
fixture.returns("{\"errors\":[" + "{" + "\"message\":\"System error\"," + "\"locations\":[{\"line\":1,\"column\":84}]," + "\"path\":[\"order\",\"items\",0,\"product\"]" + "}" + "]," + "\"data\":{" + "\"order\":{" + "\"id\":\"o1\"," + "\"items\":[" + "{\"product\":null}," + "{\"product\":null}" + "]}}}");
OrderApi api = fixture.build(OrderApi.class);
GraphQLClientException throwable = catchThrowableOfType(() -> api.order("o1"), GraphQLClientException.class);
then(fixture.query()).isEqualTo("query order($id: String!) { order(id: $id) {id orderDate items {product {id name}}} }");
then(fixture.variables()).isEqualTo("{'id':'o1'}");
then(throwable).hasExactlyOneErrorWhich().hasMessage("System error").hasPath("order", "items", 0, "product").hasSourceLocation(1, 84).hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailToMapOuterNestedError.
@Test
void shouldFailToMapOuterNestedError() {
fixture.returns(deeplyNestedError("{\"outer\":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 ErrorBehavior method shouldFailOnErrorWithNullMessage.
@Test
void shouldFailOnErrorWithNullMessage() {
fixture.returns("{\n" + " \"errors\": [\n" + " {\n" + " \"message\": null,\n" + " \"extensions\": {\n" + " \"classification\": \"SomeClassification\"\n" + " }\n" + " }\n" + " ],\n" + " \"data\": null\n" + "}\n");
StringApi api = fixture.build(StringApi.class);
GraphQLClientException thrown = catchThrowableOfType(api::greeting, GraphQLClientException.class);
then(thrown).hasExactlyOneErrorWhich().hasMessage(null).hasNoSourceLocation().hasClassification("SomeClassification").hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnErrorWithoutLocations.
@Test
void shouldFailOnErrorWithoutLocations() {
fixture.returns("{\n" + " \"errors\": [\n" + " {\n" + " \"message\": \"something went wrong\",\n" + " \"extensions\": {\n" + " \"classification\": \"SomeClassification\"\n" + " }\n" + " }\n" + " ],\n" + " \"data\": null\n" + "}\n");
StringApi api = fixture.build(StringApi.class);
GraphQLClientException thrown = catchThrowableOfType(api::greeting, GraphQLClientException.class);
then(thrown).hasExactlyOneErrorWhich().hasMessage("something went wrong").hasNoSourceLocation().hasClassification("SomeClassification").hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnErrorWithoutMessage.
@Test
void shouldFailOnErrorWithoutMessage() {
fixture.returns("{" + "\"data\":{\"greeting\":null}," + "\"errors\":[{" + /**/
"\"locations\":[{\"line\":1,\"column\":2,\"sourceName\":\"loc\"}]," + /**/
"\"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(null).hasSourceLocation(1, 2).hasPath("greeting").hasErrorCode("no-greeting");
}
Aggregations