From 18f44efe6ddabb33df715d690c872bd35161b7f4 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 13 Oct 2020 18:15:20 +0200 Subject: [PATCH] Rename and document GraphQL properties --- .../graphql/GraphQLAutoConfiguration.java | 4 +-- .../boot/graphql/GraphQLProperties.java | 26 ++++++++++++------- .../WebFluxGraphQLAutoConfiguration.java | 2 +- .../WebMvcGraphQLAutoConfiguration.java | 2 +- .../GraphQLAutoConfigurationTests.java | 4 +-- .../WebFluxApplicationContextTests.java | 2 +- .../WebMvcApplicationContextTests.java | 2 +- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java index 04415b97..315bdd69 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java +++ b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java @@ -54,12 +54,12 @@ public class GraphQLAutoConfiguration { @Bean public GraphQL.Builder graphQLBuilder(GraphQLProperties properties, RuntimeWiring runtimeWiring) { try { - File schemaFile = ResourceUtils.getFile(properties.getSchema()); + File schemaFile = ResourceUtils.getFile(properties.getSchemaLocation()); GraphQLSchema schema = buildSchema(schemaFile, runtimeWiring); return GraphQL.newGraphQL(schema); } catch (FileNotFoundException ex) { - throw new MissingGraphQLSchemaException(properties.getSchema()); + throw new MissingGraphQLSchemaException(properties.getSchemaLocation()); } } diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java index 8e8c79f0..190cb220 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java +++ b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java @@ -20,23 +20,29 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "spring.graphql") public class GraphQLProperties { - private String schema = "classpath:schema.graphqls"; + /** + * Location of the GraphQL schema file. + */ + private String schemaLocation = "classpath:schema.graphqls"; - private String url = "/graphql"; + /** + * Path of the GraphQL HTTP endpoint. + */ + private String path = "/graphql"; - public String getUrl() { - return url; + public String getPath() { + return path; } - public void setUrl(String url) { - this.url = url; + public void setPath(String path) { + this.path = path; } - public String getSchema() { - return schema; + public String getSchemaLocation() { + return schemaLocation; } - public void setSchema(String schema) { - this.schema = schema; + public void setSchemaLocation(String schemaLocation) { + this.schemaLocation = schemaLocation; } } diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java index 0cca90ee..63187d5b 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java +++ b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java @@ -49,7 +49,7 @@ public class WebFluxGraphQLAutoConfiguration { @Bean public RouterFunction graphQLQueryEndpoint(WebFluxGraphQLHandler handler, GraphQLProperties graphQLProperties) { - return RouterFunctions.route().POST(graphQLProperties.getUrl(), accept(MediaType.APPLICATION_JSON), handler).build(); + return RouterFunctions.route().POST(graphQLProperties.getPath(), accept(MediaType.APPLICATION_JSON), handler).build(); } } diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java index 4f0101cd..ea498b8c 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java +++ b/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java @@ -50,7 +50,7 @@ public class WebMvcGraphQLAutoConfiguration { @Bean public RouterFunction graphQLQueryEndpoint(WebMvcGraphQLHandler handler, GraphQLProperties graphQLProperties) { return RouterFunctions.route() - .POST(graphQLProperties.getUrl(), accept(MediaType.APPLICATION_JSON), handler) + .POST(graphQLProperties.getPath(), accept(MediaType.APPLICATION_JSON), handler) .build(); } diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java index 28e9b8d9..26887207 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java @@ -51,7 +51,7 @@ class GraphQLAutoConfigurationTests { @Test void shouldCreateBuilderWithSdl() { contextRunner - .withPropertyValues("spring.graphql.schema:classpath:books/schema.graphqls") + .withPropertyValues("spring.graphql.schema-location:classpath:books/schema.graphqls") .run((context) -> { assertThat(context).hasSingleBean(GraphQL.Builder.class); }); @@ -60,7 +60,7 @@ class GraphQLAutoConfigurationTests { @Test void shouldUseProgrammaticallyDefinedBuilder() { contextRunner - .withPropertyValues("spring.graphql.schema:classpath:books/schema.graphqls") + .withPropertyValues("spring.graphql.schema-location:classpath:books/schema.graphqls") .withUserConfiguration(CustomGraphQLBuilderConfiguration.class) .run((context) -> { assertThat(context).hasBean("customGraphQLBuilder"); diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java index 6709f8ce..58581788 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java @@ -65,7 +65,7 @@ class WebFluxApplicationContextTests { .withUserConfiguration(DataFetchersConfiguration.class) .withPropertyValues( "spring.main.web-application-type=reactive", - "spring.graphql.schema:classpath:books/schema.graphqls") + "spring.graphql.schema-location:classpath:books/schema.graphqls") .run((context) -> { WebTestClient client = WebTestClient.bindToApplicationContext(context) .configureClient() diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java index 77f708a4..7b2ad5d3 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java @@ -63,7 +63,7 @@ class WebMvcApplicationContextTests { .withUserConfiguration(DataFetchersConfiguration.class) .withPropertyValues( "spring.main.web-application-type=servlet", - "spring.graphql.schema:classpath:books/schema.graphqls") + "spring.graphql.schema-location:classpath:books/schema.graphqls") .run((context) -> { MockHttpServletRequestBuilder builder = post("/graphQL") .contentType(MediaType.APPLICATION_JSON)