Skip to content

Commit f36d94f

Browse files
committed
support sub directories in maven client plugin
1 parent e7ea357 commit f36d94f

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
query subDirQuery {
2+
enumQuery
3+
scalarQuery {
4+
count
5+
custom
6+
id
7+
name
8+
rating
9+
valid
10+
}
11+
}

integration/maven-plugin-integration-tests/integration/generate-client/src/test/kotlin/com/expediagroup/graphql/plugin/maven/GenerateClientMojoTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ class GenerateClientMojoTest {
2929
assertTrue(queryFilePath.toFile().exists(), "graphql client query file was generated")
3030
val typeAliasesFilePath = Paths.get(buildDirectory, "generated-sources", "graphql", "com", "expediagroup", "graphql", "plugin", "generated", "GraphQLTypeAliases.kt")
3131
assertTrue(typeAliasesFilePath.toFile().exists(), "graphql client type aliases were generated")
32+
val queryFilePathSubDir = Paths.get(buildDirectory, "generated-sources", "graphql", "com", "expediagroup", "graphql", "plugin", "generated", "SubDirQuery.kt")
33+
assertTrue(queryFilePathSubDir.toFile().exists(), "graphql client query sub dir file was generated")
3234
}
3335
}

plugins/graphql-kotlin-maven-plugin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Generate GraphQL client code based on the provided GraphQL schema and target que
110110
| `customScalars` | List<CustomScalar> | | Custom GraphQL scalar to converter mapping containing information about corresponding Java type and converter that should be used to serialize/deserialize values. |
111111
| `outputDirectory` | File | | Target directory where to store generated files.<br/>**Default value is**: `${project.build.directory}/generated-sources/graphql` |
112112
| `packageName` | String | yes | Target package name for generated code.<br/>**User property is**: `graphql.packageName`. |
113-
| `queryFileDirectory` | File | | Directory file containing GraphQL queries. Instead of specifying a directory you can also specify list of query file by using `queryFiles` property instead.<br/>**Default value is:** `src/main/resources`. |
113+
| `queryFileDirectory` | File | | Directory file containing GraphQL queries. They are resolved recursively. Instead of specifying a directory you can also specify list of query file by using `queryFiles` property instead.<br/>**Default value is:** `src/main/resources`. |
114114
| `queryFiles` | List<File> | | List of query files to be processed. Instead of a list of files to be processed you can also specify `queryFileDirectory` directory containing all the files. If this property is specified it will take precedence over the corresponding directory property. |
115115
| `serializer` | GraphQLSerializer | | JSON serializer that will be used to generate the data classes.<br/>**Default value is:** `GraphQLSerializer.JACKSON`. |
116116
| `schemaFile` | String | | GraphQL schema file that will be used to generate client code.<br/>**Default value is**: `${project.build.directory}/schema.graphql`<br/>**User property is**: `graphql.schemaFile`. |

plugins/graphql-kotlin-maven-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/maven/GenerateClientAbstractMojo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ abstract class GenerateClientAbstractMojo : AbstractMojo() {
150150
}
151151

152152
private fun locateQueryFiles(files: List<File>?, directory: File): List<File> {
153-
val targetQueryFiles: List<File> = files ?: directory.listFiles { file -> file.extension == "graphql" }?.toList() ?: throw RuntimeException("exception while looking up the query files")
153+
val targetQueryFiles: List<File> = files ?: directory.walkBottomUp().filter { file -> file.extension == "graphql" }.toList()
154154
if (targetQueryFiles.isEmpty()) {
155155
throw RuntimeException("no query files specified")
156156
}

0 commit comments

Comments
 (0)