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
This commit is contained in:
Patrick Strawderman 2024-02-17 21:18:37 -08:00 committed by Brian Clozel
parent 1e45d5cfa2
commit 057432c87b
2 changed files with 2 additions and 2 deletions

View File

@ -112,8 +112,8 @@ public class GraphQlWebFluxAutoConfiguration {
String path = properties.getPath();
logger.info(LogMessage.format("GraphQL endpoint HTTP POST %s", path));
RouterFunctions.Builder builder = RouterFunctions.route();
builder = builder.GET(path, this::onlyAllowPost);
builder = builder.POST(path, SUPPORTS_MEDIATYPES, httpHandler::handleRequest);
builder = builder.GET(path, this::onlyAllowPost);
if (properties.getGraphiql().isEnabled()) {
GraphiQlHandler graphQlHandler = new GraphiQlHandler(path, properties.getWebsocket().getPath());
builder = builder.GET(properties.getGraphiql().getPath(), graphQlHandler::handleRequest);

View File

@ -112,9 +112,9 @@ public class GraphQlWebMvcAutoConfiguration {
String path = properties.getPath();
logger.info(LogMessage.format("GraphQL endpoint HTTP POST %s", path));
RouterFunctions.Builder builder = RouterFunctions.route();
builder = builder.GET(path, this::onlyAllowPost);
builder = builder.POST(path, RequestPredicates.contentType(MediaType.APPLICATION_JSON)
.and(RequestPredicates.accept(SUPPORTED_MEDIA_TYPES)), httpHandler::handleRequest);
builder = builder.GET(path, this::onlyAllowPost);
if (properties.getGraphiql().isEnabled()) {
GraphiQlHandler graphiQLHandler = new GraphiQlHandler(path, properties.getWebsocket().getPath());
builder = builder.GET(properties.getGraphiql().getPath(), graphiQLHandler::handleRequest);