dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

Gradle Task To Fetch And Update Schema By URI

Open Workom2016 opened this issue 2 years ago • 3 comments

Hi, I'm using Kotlin And Gradle, I would like to fetch schema using a Gradle task and update it in the specific path in the project.

I found such capability in ExpediaGroup lib id("com.expediagroup.graphql"), but didn't find a matching solution in dgs-codegen, val tempSchemaDownload by tasks.creating(com.expediagroup.graphql.plugin.gradle.tasks.GraphQLDownloadSDLTask::class) { endpoint.set("http://...") outputFile.set(project.layout.buildDirectory.file("schema.graphql")) }

Please advise if there's a way and I'm missing something

Workom2016 avatar Feb 23 '23 18:02 Workom2016

We don't have the ability to fetch a schema from a URI. There is a way to include schema files from dependency JARs but not to fetch remote schemas.

srinivasankavitha avatar Feb 23 '23 18:02 srinivasankavitha

Hi, I'm using Kotlin And Gradle, too

The client module is trying to use dgsCodegen.

build.gradle.kts ...



plugins {
    id("com.netflix.dgs.codegen")
}

dependencies {
    dgsCodegen(project(":apps:api"))
}

tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
    generateClientv2 = true
    generatedSourcesDir = project.buildDir.absolutePath
    packageName = "com.zshp.agg.stream"
    typeMapping = mutableMapOf(
        // Scalar
        "Long" to "kotlin.Long",
        "BigDecimal" to "java.math.BigDecimal",
        "DateTime" to "java.time.OffsetDateTime"
    )
}

dgsCodegen is not working. can't you support bringing it within the multi-module? image image

Please advise if there's a way and I'm missing something

zaety777 avatar Jun 20 '23 13:06 zaety777

Are you using the latest release? That would be the first thing to check since we had to revert a change that affcted this feature.

If it's still not working: Usually you need the group id and artifact for specifying the dependency like so

dependencies {
    // other dependencies
    dgsCodegen 'com.netflix.graphql.dgs:example-schema:x.x.x'
}

I don't think it would work with the internal module as you have specified, we haven't explicitly tried to support that.

srinivasankavitha avatar Jun 20 '23 16:06 srinivasankavitha