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 eade0dd7..820fef6b 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 @@ -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. diff --git a/graphql-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/graphql-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 38f69f69..008016c4 100644 --- a/graphql-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/graphql-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -2,7 +2,7 @@ "properties": [ { "name": "spring.graphql.schema.locations", - "defaultValue": "classpath:graphql/" + "defaultValue": "classpath:graphql/**/" }, { "name": "spring.graphql.schema.file-extensions", diff --git a/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQlAutoConfigurationTests.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQlAutoConfigurationTests.java index bffc3248..90a9aa5c 100644 --- a/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQlAutoConfigurationTests.java +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQlAutoConfigurationTests.java @@ -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/") diff --git a/graphql-spring-boot-starter/src/test/resources/graphql/queries.graphqls b/graphql-spring-boot-starter/src/test/resources/graphql/queries.graphqls new file mode 100644 index 00000000..437080c6 --- /dev/null +++ b/graphql-spring-boot-starter/src/test/resources/graphql/queries.graphqls @@ -0,0 +1,3 @@ +type Query { + bookById(id: ID): Book +} \ No newline at end of file diff --git a/graphql-spring-boot-starter/src/test/resources/graphql/types/book.graphqls b/graphql-spring-boot-starter/src/test/resources/graphql/types/book.graphqls new file mode 100644 index 00000000..20613439 --- /dev/null +++ b/graphql-spring-boot-starter/src/test/resources/graphql/types/book.graphqls @@ -0,0 +1,5 @@ +type Book { + id: ID + name: String + pageCount: Int +} \ No newline at end of file