From a719ba0231db676fdd3c614c8748bf12cc911450 Mon Sep 17 00:00:00 2001 From: sadv1r <5000487+sadv1r@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:39:16 +0300 Subject: [PATCH] Adjusted the server path to include the context path --- .../configuration/GraphiQlWebFluxAutoConfiguration.java | 4 +++- .../configuration/GraphiQlWebMvcAutoConfiguration.java | 4 +++- .../PlaygroundWebFluxMvcAutoConfiguration.java | 4 +++- .../configuration/PlaygroundWebMvcAutoConfiguration.java | 4 +++- .../configuration/VoyagerWebFluxAutoConfiguration.java | 6 ++++-- .../configuration/VoyagerWebMvcAutoConfiguration.java | 6 ++++-- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebFluxAutoConfiguration.java b/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebFluxAutoConfiguration.java index 0207ca3..04bc98b 100644 --- a/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebFluxAutoConfiguration.java +++ b/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebFluxAutoConfiguration.java @@ -24,9 +24,11 @@ public class GraphiQlWebFluxAutoConfiguration { @Order(-1) public RouterFunction reactiveGraphiQlRouterFunction(GraphiqlProperties properties, @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("graphiql") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("query", properties.getQuery()) .modelAttribute("defaultEditorToolsVisibility", properties.getDefaultEditorToolsVisibility()) .modelAttribute("variables", properties.getVariables()) diff --git a/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebMvcAutoConfiguration.java b/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebMvcAutoConfiguration.java index d1521f0..c1fde92 100644 --- a/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebMvcAutoConfiguration.java +++ b/graphql-graphiql-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/graphiql/configuration/GraphiQlWebMvcAutoConfiguration.java @@ -21,9 +21,11 @@ public class GraphiQlWebMvcAutoConfiguration { @Order(-1) public RouterFunction graphiQlRouterFunction(GraphiqlProperties properties, @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("graphiql") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("query", properties.getQuery()) .modelAttribute("defaultEditorToolsVisibility", properties.getDefaultEditorToolsVisibility()) .modelAttribute("variables", properties.getVariables()) diff --git a/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebFluxMvcAutoConfiguration.java b/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebFluxMvcAutoConfiguration.java index 2f1b4f7..4046ba2 100644 --- a/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebFluxMvcAutoConfiguration.java +++ b/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebFluxMvcAutoConfiguration.java @@ -24,9 +24,11 @@ public class PlaygroundWebFluxMvcAutoConfiguration { @Order(-1) public RouterFunction reactivePlaygroundRouterFunction(PlaygroundProperties properties, @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("playground") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("settings", properties.getSettings()) .modelAttribute("headers", properties.getHeaders()) .modelAttribute("tabs", properties.getTabs()) diff --git a/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebMvcAutoConfiguration.java b/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebMvcAutoConfiguration.java index 2a285cb..3192a0e 100644 --- a/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebMvcAutoConfiguration.java +++ b/graphql-playground-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/playground/configuration/PlaygroundWebMvcAutoConfiguration.java @@ -21,9 +21,11 @@ public class PlaygroundWebMvcAutoConfiguration { @Order(-1) public RouterFunction playgroundRouterFunction(PlaygroundProperties properties, @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("playground") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("settings", properties.getSettings()) .modelAttribute("headers", properties.getHeaders()) .modelAttribute("tabs", properties.getTabs()) diff --git a/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebFluxAutoConfiguration.java b/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebFluxAutoConfiguration.java index 0d9f116..478fdae 100644 --- a/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebFluxAutoConfiguration.java +++ b/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebFluxAutoConfiguration.java @@ -23,10 +23,12 @@ public class VoyagerWebFluxAutoConfiguration { @Bean @Order(-1) public RouterFunction reactiveVoyagerRouterFunction(VoyagerProperties properties, - @Value("${spring.graphql.path:/graphql}") String serverPath) { + @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("voyager") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("displayOptions", properties.getDisplayOptions()) .modelAttribute("hideDocs", properties.isHideDocs()) .modelAttribute("hideSettings", properties.isHideSettings()) diff --git a/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebMvcAutoConfiguration.java b/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebMvcAutoConfiguration.java index 2377cf4..0614cd4 100644 --- a/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebMvcAutoConfiguration.java +++ b/graphql-voyager-spring-boot-starter/src/main/java/ru/sadv1r/spring/graphql/editor/voyager/configuration/VoyagerWebMvcAutoConfiguration.java @@ -20,10 +20,12 @@ public class VoyagerWebMvcAutoConfiguration { @Bean @Order(-1) public RouterFunction voyagerRouterFunction(VoyagerProperties properties, - @Value("${spring.graphql.path:/graphql}") String serverPath) { + @Value("${spring.graphql.path:/graphql}") String serverPath) { + String pathWithContext = serverPath.startsWith("/") ? serverPath : "/" + serverPath; + final HandlerFunction handler = e -> RenderingResponse.create("voyager") .modelAttribute("cdnHost", properties.getCdn().getHost()) - .modelAttribute("serverPath", serverPath) + .modelAttribute("serverPath", e.requestPath().contextPath().value() + pathWithContext) .modelAttribute("displayOptions", properties.getDisplayOptions()) .modelAttribute("hideDocs", properties.isHideDocs()) .modelAttribute("hideSettings", properties.isHideSettings())