Deserialize errorType from extensions

The errorType field on GraphQLError is specific to GraphQL Java and when
serialized via GraphqlErrorHelper#toSpecification it becomes an
extension with the key "classification".

This commit ensures that we correctly deserialize back to errorType from
the "classification" extension but unfortunately that's limited to the
ErrorClassification enums that we know of.
This commit is contained in:
Rossen Stoyanchev
2021-06-29 14:52:33 +01:00
parent 71ce400e4f
commit bbf152a32f
3 changed files with 24 additions and 21 deletions

View File

@@ -51,8 +51,7 @@ class SampleApplicationTests {
.errors()
.satisfy(errors -> {
assertThat(errors).hasSize(1);
assertThat(errors.get(0).getExtensions().get("classification"))
.isEqualTo(ErrorType.UNAUTHORIZED.name());
assertThat(errors.get(0).getErrorType()).isEqualTo(ErrorType.UNAUTHORIZED);
});
}
@@ -71,8 +70,7 @@ class SampleApplicationTests {
.errors()
.satisfy(errors -> {
assertThat(errors).hasSize(1);
assertThat(errors.get(0).getExtensions().get("classification"))
.isEqualTo(ErrorType.FORBIDDEN.name());
assertThat(errors.get(0).getErrorType()).isEqualTo(ErrorType.FORBIDDEN);
});
}
@@ -103,8 +101,7 @@ class SampleApplicationTests {
.errors()
.satisfy(errors -> {
assertThat(errors).hasSize(1);
assertThat(errors.get(0).getExtensions().get("classification"))
.isEqualTo(ErrorType.UNAUTHORIZED.name());
assertThat(errors.get(0).getErrorType()).isEqualTo(ErrorType.UNAUTHORIZED);
});
}