Scan nested locations for GraphQL schema files
This commit changes the default value for the `spring.graphql.locations` configuration property to `classpath:/graphql/**/`. By default, this will scan nested locations for GraphQL schema files. Fixes gh-210
This commit is contained in:
@@ -66,7 +66,7 @@ public class GraphQlProperties {
|
||||
/**
|
||||
* Locations of GraphQL schema files.
|
||||
*/
|
||||
private String[] locations = new String[] { "classpath:graphql/"};
|
||||
private String[] locations = new String[] { "classpath:graphql/**/"};
|
||||
|
||||
/**
|
||||
* File extensions for GraphQL schema files.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"properties": [
|
||||
{
|
||||
"name": "spring.graphql.schema.locations",
|
||||
"defaultValue": "classpath:graphql/"
|
||||
"defaultValue": "classpath:graphql/**/"
|
||||
},
|
||||
{
|
||||
"name": "spring.graphql.schema.file-extensions",
|
||||
|
||||
@@ -40,10 +40,11 @@ class GraphQlAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void shouldFailWhenSchemaFileIsMissing() {
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().getRootCause().isInstanceOf(MissingSchemaException.class);
|
||||
});
|
||||
this.contextRunner.withPropertyValues("spring.graphql.schema.locations:classpath:missing/")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().getRootCause().isInstanceOf(MissingSchemaException.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,6 +53,11 @@ class GraphQlAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldScanNestedLocations() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldUseProgrammaticallyDefinedBuilder() {
|
||||
this.contextRunner.withPropertyValues("spring.graphql.schema.locations:classpath:books/")
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
type Query {
|
||||
bookById(id: ID): Book
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
type Book {
|
||||
id: ID
|
||||
name: String
|
||||
pageCount: Int
|
||||
}
|
||||
Reference in New Issue
Block a user