From 2be79c2c732963120fda01a8f55ab4d4a9442221 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 2 Jul 2021 13:57:36 +0200 Subject: [PATCH] Remove configuration key for GraphQL schema path Currently, the GraphQL schema is exposed under /graphql/schema (so relative to the main graphql endpoint) and is configurable with the `spring.graphql.schema.printer.path` configuration property. We think we should make the schema location more consistent to help tools and various Gateway products. Also, we don't see right now a strong use case for such a configuration property. This commit removes the configuration property and sets the schema location under `/graphql/schema`(`/graphql` being the main graphql path configured by the application). Closes gh-79 --- .../graphql/boot/GraphQlProperties.java | 13 ------------- .../boot/GraphQlWebFluxAutoConfiguration.java | 4 +--- .../boot/GraphQlWebMvcAutoConfiguration.java | 3 +-- spring-graphql-docs/src/docs/asciidoc/index.adoc | 3 ++- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlProperties.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlProperties.java index 9032b899..91ce87f3 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlProperties.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlProperties.java @@ -98,11 +98,6 @@ public class GraphQlProperties { */ private boolean enabled = false; - /** - * Path under the main GraphQL path where the schema is exposed. - */ - private String path = "/schema"; - public boolean isEnabled() { return this.enabled; } @@ -111,14 +106,6 @@ public class GraphQlProperties { this.enabled = enabled; } - public String getPath() { - return this.path; - } - - public void setPath(String path) { - this.path = path; - } - } } diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebFluxAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebFluxAutoConfiguration.java index 5d546f11..2f126ac6 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebFluxAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebFluxAutoConfiguration.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.stream.Collectors; import graphql.GraphQL; -import graphql.schema.idl.SchemaPrinter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -115,8 +114,7 @@ public class GraphQlWebFluxAutoConfiguration { if (properties.getSchema().getPrinter().isEnabled()) { SchemaHandler schemaHandler = new SchemaHandler(graphQlSource); - String schemaPath = properties.getSchema().getPrinter().getPath(); - builder = builder.GET(graphQLPath + schemaPath, schemaHandler::handleRequest); + builder = builder.GET(graphQLPath + "/schema", schemaHandler::handleRequest); } return builder.build(); diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebMvcAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebMvcAutoConfiguration.java index 9732c7e0..51553c37 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebMvcAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlWebMvcAutoConfiguration.java @@ -124,8 +124,7 @@ public class GraphQlWebMvcAutoConfiguration { if (properties.getSchema().getPrinter().isEnabled()) { SchemaHandler schemaHandler = new SchemaHandler(graphQlSource); - String schemaPath = properties.getSchema().getPrinter().getPath(); - builder = builder.GET(graphQLPath + schemaPath, schemaHandler::handleRequest); + builder = builder.GET(graphQLPath + "/schema", schemaHandler::handleRequest); } return builder.build(); diff --git a/spring-graphql-docs/src/docs/asciidoc/index.adoc b/spring-graphql-docs/src/docs/asciidoc/index.adoc index 96171c54..f300d0ae 100644 --- a/spring-graphql-docs/src/docs/asciidoc/index.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/index.adoc @@ -183,7 +183,8 @@ schema locations to check as follows: spring.graphql.schema.locations=classpath:graphql/ ---- -The GraphQL schema can be viewed over HTTP at "/graphql/schema", if enabled: +The GraphQL schema can be viewed over HTTP at "/graphql/schema", relative to the main graphql endpoint path. +It is disabled by default: [source,properties,indent=0,subs="verbatim,quotes"] ----