织梦CMS - 轻松建站从此开始!

abg欧博官网|登陆|游戏|

当前位置: abg欧博官网|登陆|游戏| > 欧博平台 > 文章页

Netflix GraphQL DGS Codegen "dgsCodegen"

时间:2025-08-06 14:59来源: 作者:admin 点击: 14 次
Don't know whether my expectation is just plain unrealistic, or whether the DGS documentation is just really incomprehensible - cos this seems simple

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 works as expected;

says;

You can also specify external dependencies containing schemas to use for generation by declaring it as a dependency in the dgsCodegen configuration. The plugin will scan all .graphql and .graphqls files and generate those classes under the same build/generated directory. 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 pulishToMavenLocal to install the library locally

cd into application then ./gradlew clean build to 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 .

Could someone kindly point me towards what's being done incorrectly here?

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-08-23 15:08 最后登录:2025-08-23 15:08
栏目列表
推荐内容