From 86cc18b9cca8d5732859d062e5709b99fa612494 Mon Sep 17 00:00:00 2001 From: szalai1 Date: Thu, 19 Jan 2023 17:33:57 +0100 Subject: [PATCH] fix(graphql): Return with appropriate status code instead of stacktrace --- .../main/java/com/datahub/graphql/GraphQLController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java b/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java index c7f8ffbae1d683..a616cfb4bdda95 100644 --- a/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java +++ b/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java @@ -25,6 +25,7 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -123,8 +124,9 @@ CompletableFuture> postGraphQL(HttpEntity httpEnt } @GetMapping("/graphql") - void getGraphQL(HttpServletRequest request, HttpServletResponse response) { - throw new UnsupportedOperationException("GraphQL gets not supported."); + void getGraphQL(HttpServletRequest request, HttpServletResponse response) throws HttpRequestMethodNotSupportedException { + log.info("GET on GraphQL API is not supported"); + throw new HttpRequestMethodNotSupportedException("GET"); } private void observeErrors(ExecutionResult executionResult) {