Netflix / dgs-intellij-plugin

Apache License 2.0
22 stars 11 forks source link

DGS plugin gives a warning saying @InputArgument name input does not match the schema #76

Closed feline87 closed 1 year ago

feline87 commented 1 year ago

DGS plugin shows a warning that says: "@InputArgument name input does not match the schema, valid argument names: [product]."

I know it doesn't match the schema. That's why I'm specifying it inside the annotation.


@DgsMutation
    fun editProduct(@InputArgument("product") input: ProductInput): ProductResult {
        val product = productService.findProductByUuid(UUID.fromString(input.id))
            ?: throw IllegalArgumentException("Product not found: UUID: ${input.id}")
        product.title = input.title
        product.description = input.description
        product.price = BigDecimal.valueOf(input.price)
        val savedProduct = productService.saveProduct(product)
        return converter.fromEntity(savedProduct)
    }
}
aabdelhafez commented 1 year ago

@feline87 As bizarre as it may be, this warning can be temporarily fixed by using named arguments 😄

@DgsMutation
fun editProduct(@InputArgument(name = "product") input: ProductInput): ProductResult {}
//                              👆
srinivasankavitha commented 1 year ago

That is the expected behavior, i.e. when the name of the argument does not match the field name in the schema, we need to specify it explicitly in the annotation's name argument.