https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
d

Dusan Hornik

10/19/2020, 10:42 AM
Hi is there a way to disable adding “Input” suffix for Graphql input types?
d

Dariusz Kuc

10/19/2020, 2:01 PM
hi 👋 there is no option to disable it globally but you can overwrite individual entries using
@GraphQLName
see https://expediagroup.github.io/graphql-kotlin/docs/schema-generator/customizing-schemas/renaming-fields
d

Dusan Hornik

10/19/2020, 11:54 PM
Thanks, I tried it, it still added the Input at the end.
note: renaming input object will most likely require custom data fetcher logic to correctly serialize the renamed input type to corresponding graphql type (or I guess jackson annotation might work as well)
d

Dusan Hornik

10/21/2020, 2:30 AM
Thanks Dariusz, The test you linked is actually showing that the Input suffix is always added. The
@GraphQLName
annotation says the type name should be
InputClassRenamed
Copy code
@GraphQLName("InputClassRenamed")
    private class InputClassCustomName {
        @GraphQLName("myFieldRenamed")
        val myField: String = "car"
    }
But the test asserts that the name is
InputClassRenamedInput
:
Copy code
@Test
fun `Test custom naming on classes`() {
    val result = generateInputObject(generator, InputClassCustomName::class)
    assertEquals("InputClassRenamedInput", result.name)
}
Anyway it’s not a big deal I think we can live with
Input
suffix 🙂
d

Dariusz Kuc

10/21/2020, 3:06 AM
My bad, indeed it seems we always append input
31 Views