Skip to content

Commit

Permalink
fix return status code for bad requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dariuszkuc committed Jun 3, 2024
1 parent ad1b1c9 commit a9a0e30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.springframework.graphql.server.WebGraphQlResponse;
import org.springframework.graphql.server.WebSocketGraphQlRequest;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -65,7 +67,7 @@ public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain
if (logger.isErrorEnabled()) {
logger.error("Unable to start subscription using callback protocol", error);
}
return Mono.just(errorCallbackResponse(request));
return Mono.error(new ResponseStatusException(HttpStatus.BAD_REQUEST));
});
} else {
return chain.next(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public void verifyMalformedCallbackInfo(WebTestClient testClient) {
.bodyValue(graphQLRequest)
.exchange()
.expectStatus()
.is4xxClientError()
.expectBody()
.isEmpty();
.is4xxClientError();
}

public void verifyFailedCallbackInit(WebTestClient testClient) {
Expand All @@ -116,8 +114,6 @@ public void verifyFailedCallbackInit(WebTestClient testClient) {
.bodyValue(graphQLRequest)
.exchange()
.expectStatus()
.is4xxClientError()
.expectBody()
.isEmpty();
.is4xxClientError();
}
}

0 comments on commit a9a0e30

Please sign in to comment.