Skip to content

Commit 057432c

Browse files
kilinkbclozel
authored andcommitted
Re-order route registration for GraphQL web endpoints
Re-order the route registrations for GraphQL requests so that the most commonly matched path is evaluated first. Closes gh-39613
1 parent 1e45d5c commit 057432c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public RouterFunction<ServerResponse> graphQlRouterFunction(GraphQlHttpHandler h
112112
String path = properties.getPath();
113113
logger.info(LogMessage.format("GraphQL endpoint HTTP POST %s", path));
114114
RouterFunctions.Builder builder = RouterFunctions.route();
115-
builder = builder.GET(path, this::onlyAllowPost);
116115
builder = builder.POST(path, SUPPORTS_MEDIATYPES, httpHandler::handleRequest);
116+
builder = builder.GET(path, this::onlyAllowPost);
117117
if (properties.getGraphiql().isEnabled()) {
118118
GraphiQlHandler graphQlHandler = new GraphiQlHandler(path, properties.getWebsocket().getPath());
119119
builder = builder.GET(properties.getGraphiql().getPath(), graphQlHandler::handleRequest);

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public RouterFunction<ServerResponse> graphQlRouterFunction(GraphQlHttpHandler h
112112
String path = properties.getPath();
113113
logger.info(LogMessage.format("GraphQL endpoint HTTP POST %s", path));
114114
RouterFunctions.Builder builder = RouterFunctions.route();
115-
builder = builder.GET(path, this::onlyAllowPost);
116115
builder = builder.POST(path, RequestPredicates.contentType(MediaType.APPLICATION_JSON)
117116
.and(RequestPredicates.accept(SUPPORTED_MEDIA_TYPES)), httpHandler::handleRequest);
117+
builder = builder.GET(path, this::onlyAllowPost);
118118
if (properties.getGraphiql().isEnabled()) {
119119
GraphiQlHandler graphiQLHandler = new GraphiQlHandler(path, properties.getWebsocket().getPath());
120120
builder = builder.GET(properties.getGraphiql().getPath(), graphiQLHandler::handleRequest);

0 commit comments

Comments
 (0)