Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 45a73bd

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 81ebb34 + 7cc4d79 commit 45a73bd

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

graphql-kickstart-spring-support/src/main/java/graphql/kickstart/spring/error/ErrorContext.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
package graphql.kickstart.spring.error;
22

3+
import graphql.ErrorClassification;
34
import graphql.language.SourceLocation;
45

56
import java.util.List;
7+
import java.util.Map;
68

79
public class ErrorContext {
810
private final List<SourceLocation> locations;
911
private final List<Object> path;
12+
private final Map<String, Object> extensions;
13+
private final ErrorClassification errorType;
1014

11-
public ErrorContext(List<SourceLocation> locations, List<Object> path) {
15+
public ErrorContext(List<SourceLocation> locations,
16+
List<Object> path,
17+
Map<String, Object> extensions,
18+
ErrorClassification errorType) {
1219
this.locations = locations;
1320
this.path = path;
21+
this.extensions = extensions;
22+
this.errorType = errorType;
1423
}
1524

1625
public List<SourceLocation> getLocations() {
@@ -20,4 +29,12 @@ public List<SourceLocation> getLocations() {
2029
public List<Object> getPath() {
2130
return path;
2231
}
32+
33+
public Map<String, Object> getExtensions() {
34+
return extensions;
35+
}
36+
37+
public ErrorClassification getErrorType() {
38+
return errorType;
39+
}
2340
}

graphql-kickstart-spring-support/src/main/java/graphql/kickstart/spring/error/GraphQLErrorFromExceptionHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ protected List<GraphQLError> filterGraphQLErrors(List<GraphQLError> errors) {
3232
}
3333

3434
private Collection<GraphQLError> transform(GraphQLError error) {
35-
ErrorContext errorContext = new ErrorContext(error.getLocations(), error.getPath());
35+
ErrorContext errorContext = new ErrorContext(
36+
error.getLocations(),
37+
error.getPath(),
38+
error.getExtensions(),
39+
error.getErrorType()
40+
);
3641
return extractException(error).map(throwable -> transform(throwable, errorContext))
3742
.orElse(singletonList(new GenericGraphQLError(error.getMessage())));
3843
}

0 commit comments

Comments
 (0)