Skip to content

Commit 803df55

Browse files
committed
Merge branch '1.3.x'
2 parents 99594c4 + db78043 commit 803df55

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

spring-graphql/src/main/java/org/springframework/graphql/client/ResponseMapGraphQlResponse.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ public ErrorClassification getErrorType() {
177177
return graphql.ErrorType.valueOf(classification);
178178
}
179179
catch (IllegalArgumentException ex) {
180-
return org.springframework.graphql.execution.ErrorType.valueOf(classification);
180+
try {
181+
return org.springframework.graphql.execution.ErrorType.valueOf(classification);
182+
}
183+
catch (IllegalArgumentException ex2) {
184+
return ErrorClassification.errorClassification(classification);
185+
}
181186
}
182187
}
183188

spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import graphql.GraphQL;
2727
import graphql.GraphQLContext;
2828
import graphql.GraphQLError;
29-
import graphql.GraphQLException;
3029
import graphql.execution.ExecutionIdProvider;
3130
import graphql.execution.instrumentation.dataloader.EmptyDataLoaderRegistryInstance;
3231
import io.micrometer.context.ContextSnapshotFactory;
@@ -105,12 +104,8 @@ public final Mono<ExecutionGraphQlResponse> execute(ExecutionGraphQlRequest requ
105104
ExecutionInput executionInputToUse = registerDataLoaders(executionInput);
106105

107106
return Mono.fromFuture(this.graphQlSource.graphQl().executeAsync(executionInputToUse))
108-
.onErrorResume(GraphQLException.class, (exception) -> {
109-
if (exception instanceof GraphQLError graphQLError) {
110-
return Mono.just(ExecutionResult.newExecutionResult().addError(graphQLError).build());
111-
}
112-
return Mono.error(exception);
113-
})
107+
.onErrorResume((ex) -> ex instanceof GraphQLError, (ex) ->
108+
Mono.just(ExecutionResult.newExecutionResult().addError((GraphQLError) ex).build()))
114109
.map((result) -> new DefaultExecutionGraphQlResponse(executionInputToUse, result));
115110
});
116111
}

spring-graphql/src/test/java/org/springframework/graphql/execution/DefaultExecutionGraphQlServiceTests.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ void customDataLoaderRegistry() {
6767

6868
@Test
6969
void shouldHandleGraphQlErrors() {
70-
GraphQlSource graphQlSource = GraphQlSetup.schemaContent("type Query { greeting: String }")
70+
ExecutionGraphQlResponse response = GraphQlSetup.schemaContent("type Query { greeting: String }")
7171
.queryFetcher("greeting", (env) -> "hi")
72-
.toGraphQlSource();
73-
DefaultExecutionGraphQlService graphQlService = new DefaultExecutionGraphQlService(graphQlSource);
72+
.toGraphQlService()
73+
.execute(new DefaultExecutionGraphQlRequest("{ greeting }", "unknown", null, null, "uniqueId", null))
74+
.block();
7475

75-
ExecutionGraphQlRequest request = new DefaultExecutionGraphQlRequest("{ greeting }", "unknown",
76-
null, null, "uniqueId", null);
77-
ExecutionGraphQlResponse response = graphQlService.execute(request).block();
7876
assertThat(response.getExecutionResult().getErrors()).singleElement()
7977
.hasFieldOrPropertyWithValue("errorType", ErrorType.ValidationError);
8078
}

0 commit comments

Comments
 (0)