Skip to content

Commit

Permalink
#282: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
t1 committed Jun 19, 2020
1 parent c41d97b commit 8cbb4e5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions client/generator-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.graphql</groupId>
<artifactId>microprofile-graphql-api</artifactId>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

@Retention(RUNTIME)
@Target({ TYPE, ANNOTATION_TYPE })
public @interface GraphQlErrorCode {
public @interface ErrorCode {
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import graphql.ExceptionWhileDataFetching;
import graphql.GraphQLError;
import graphql.validation.ValidationError;
import io.smallrye.graphql.api.GraphQlErrorCode;
import io.smallrye.graphql.api.ErrorCode;

/**
* Help to create the exceptions
Expand Down Expand Up @@ -94,7 +94,8 @@ private Optional<JsonObject> getDataFetchingExtensions(ExceptionWhileDataFetchin
}

private String toErrorCode(Throwable exception) {
GraphQlErrorCode annotation = exception.getClass().getAnnotation(GraphQlErrorCode.class);
// TODO change to use the Model and the model needs to get this using Jandex
ErrorCode annotation = exception.getClass().getAnnotation(ErrorCode.class);
return (annotation == null)
? camelToKebab(exception.getClass().getSimpleName().replaceAll("Exception$", ""))
: annotation.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import graphql.language.SourceLocation;
import graphql.validation.ValidationError;
import graphql.validation.ValidationErrorType;
import io.smallrye.graphql.api.GraphQlErrorCode;
import io.smallrye.graphql.api.ErrorCode;

/**
* Test for {@link ExecutionErrorsService}
Expand Down Expand Up @@ -91,7 +91,7 @@ public DummyBusinessException(String message) {

@Test
void shouldMapClassAnnotationErrorCode() {
@GraphQlErrorCode("dummy-code")
@ErrorCode("dummy-code")
class DummyBusinessException extends RuntimeException {
public DummyBusinessException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;

import io.smallrye.graphql.api.GraphQlErrorCode;
import io.smallrye.graphql.api.ErrorCode;

@GraphQLApi
public class ErrorApi {
Expand All @@ -20,7 +20,7 @@ public String customBusinessException() {
throw new CustomBusinessException();
}

@GraphQlErrorCode("some-business-error-code")
@ErrorCode("some-business-error-code")
public static class AnnotatedCustomBusinessException extends RuntimeException {
}

Expand Down

0 comments on commit 8cbb4e5

Please sign in to comment.