use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnValidationError.
@Test
void shouldFailOnValidationError() {
fixture.returns("{\n" + " \"errors\": [\n" + " {\n" + " \"message\": \"Validation error of type FieldUndefined: Field 'foo' in type 'Query' is undefined @ 'foo'\",\n" + " \"locations\": [\n" + " {\n" + " \"line\": 1,\n" + " \"column\": 8\n" + " }\n" + " ]," + " \"extensions\": {\n" + " \"description\": \"Field 'foo' in type 'Query' is undefined\",\n" + " \"validationErrorType\": \"FieldUndefined\",\n" + " \"queryPath\": [\n" + " \"foo\"\n" + " ],\n" + " \"classification\": \"ValidationError\"\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("Validation error of type FieldUndefined: Field 'foo' in type 'Query' is undefined @ 'foo'").hasSourceLocation(1, 8).hasExtension("description", "Field 'foo' in type 'Query' is undefined").hasExtension("validationErrorType", "FieldUndefined").hasExtension("classification", "ValidationError").hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnErrorWithEmptyLocations.
@Test
void shouldFailOnErrorWithEmptyLocations() {
fixture.returns("{\n" + " \"errors\": [\n" + " {\n" + " \"message\": \"something went wrong\",\n" + " \"locations\": []," + " \"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").hasSourceLocations().hasClassification("SomeClassification").hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFailOnErrorWithoutExtensions.
@Test
void shouldFailOnErrorWithoutExtensions() {
fixture.returns("{\n" + " \"errors\": [\n" + " {\n" + " \"message\": \"something went wrong\",\n" + " \"locations\": [\n" + " {\n" + " \"line\": 1,\n" + " \"column\": 8\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").hasSourceLocation(1, 8).hasErrorCode(null);
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFetchErrorOnNullData.
@Test
void shouldFetchErrorOnNullData() {
fixture.returns("{" + "\"data\":null," + "\"errors\":[{" + /**/
"\"message\":\"currently can't search for teams\"," + /**/
"\"locations\":[{\"line\":1,\"column\":2,\"sourceName\":\"loc\"}]," + /**/
"\"path\": [\"teams\"],\n" + /**/
"\"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").hasPath("teams").hasSourceLocation(1, 2).hasErrorCode("team-search-disabled");
}
use of io.smallrye.graphql.client.GraphQLClientException in project smallrye-graphql by smallrye.
the class ErrorBehavior method shouldFetchErrorOrWithNullInPath.
@Test
void shouldFetchErrorOrWithNullInPath() {
fixture.returns("{" + "\"data\":{\"teams\":null}," + "\"errors\":[{" + /**/
"\"message\":\"can't get team name\"," + /**/
"\"locations\":[{\"line\":1,\"column\":2,\"sourceName\":\"loc\"}]," + /**/
"\"path\": [\"teams\",\"name\"],\n" + /**/
"\"extensions\":{" + /**/
"\"code\":\"team-name-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("can't get team name").hasPath("teams", "name").hasSourceLocation(1, 2).hasErrorCode("team-name-disabled");
}
Aggregations