Rename and document GraphQL properties
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WebFluxGraphQLAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class WebMvcGraphQLAutoConfiguration {
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user