Don't know whether my expectation is just plain unrealistic, or whether the DGS documentation is just really incomprehensible - cos this seems simple enough, however none of what was described in this section of the Netflix DGS Docs works as expected;
Netflix DGS Docs says;
You can also specify external dependencies containing schemas to use for generation by declaring it as a dependency in the
dgsCodegenconfiguration. The plugin will scan all.graphqland.graphqlsfiles and generate those classes under the samebuild/generateddirectory. This is useful if you have external dependencies containing some shared types that you want to add to your schema for code generation. Note that this does NOT affect your project's schema, and is only for code generation.
Example:
dependencies {
// other dependencies
dgsCodegen 'com.netflix.graphql.dgs:example-schema:x.x.x'
}
So to work with this, I have two projects structured as follows:
shared-schemas project structure
shared-schemas
|
--- src/main/resources/schema
| |
| --- shared-models.graphqls
|
--- build.gradle
|
--- settings.gradle
shared-schemas build.gradle
plugins {
id "java-library"
}
group = 'com.shared.library'
// ... other configs
shared-library settings.gradle
rootProject.name = 'shared-schemas'
application project structure
application
|
--- src/main/resources/schema
| |
| --- application-models.graphqls
|
--- build.gradle
|
--- settings.gradle
application build.gradle
plugins {
id "com.netflix.dgs.codegen" version "6.1.3"
}
// ... other configs
dependencies {
dgsCodegen 'com.shared.library:shared-schemas:0.0.1-SNAPSHOT'
}
generateJava {
schemaPaths = ["src/main/resources/schema"] // List of directories containing schema files
packageName = "com.application.graphql.schemas" // The package name to use to generate sources
generateClient = true // Enable generating the type safe query API
}
Then I carry out the following gradle build steps;
cd into shared-schemas then
./gradlew pulishToMavenLocalto install the library locallycd into application then
./gradlew clean buildto build the application which references the library as a dependency.
After these, the application build was successful, and GraphQL models defined inside application-models.graphqls are all created into build/generated folder. However the GraphQL models that were defined in shared-models.graphqls (within the shared-schemas library) aren't generated, and aren't inside the build/generated folder as the DGS docs suggest.
Could someone kindly point me towards what's being done incorrectly here?