2

I added the following type and enum to my schema.graphql

enum Currency {
    USD
    EUR
    GBP
    AUD
    CAD
    ILS
    HKD
    SEK
    NZD
    SGD
    CHF
    ZAR
    BRL
    CNY
    INR
    MYR
    MXN
    PKR
    PHP
    TWD
    THB
    TRY
    AED
}

type Money {
    amount: Int!
    currency: Currency!
}

and then ran generateJava. And the result is the following

package com.example.apps.financial_analytics_kimera.generated.graphql.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import java.util.Currency
import kotlin.Int

public data class Money(
  @JsonProperty("amount")
  public val amount: Int,
  @JsonProperty("currency")
  public val currency: Currency
) {
  public companion object
}

So basically there is an unnecessary import java.util.currency here which breaks my code because I want my code to use the enum currency instead of java.util.currency

What can I do to remove make generateJava not import Currency from utils? Thanks

1 Answers1

0

Apparently in Netflix DGS plugin I can configure the type representation for Scalars

Example from build.gradle.kts

val string = String::class.qualifiedName!!
val long = Long::class.qualifiedName!!
val double = Double::class.qualifiedName!!
tasks.withType<GenerateJavaTask> {
    packageName = "com.example.apps.sellers_phoenix.graphql.generated"
    typeMapping = mutableMapOf(
        "MoneyAmount" to double,
        "Timestamp" to long,
        "URI" to string,
        "BigInt" to long,
        "PageInfo" to "com.example.apps.sellers_phoenix.api.graphql.model.PageInfo"
    )
    generateClient = true
}