the following constantly throws a ClassCastExcepti...
# graphql-kotlin
m
the following constantly throws a ClassCastException
class java.util.LinkedHashMap cannot be cast to class com.expediagroup.graphql.examples.server.spring.query.ScalarQuery$PhoneNumber
Copy code
fun convolutedExample(optListInput: OptionalInput<List<PhoneNumber>>): String {
        return patient
            .let { if (it is OptionalInput.Defined) it.value else null }
            ?.map { it.number }
            .toString()
    }

    data class PhoneNumber(val number: Long)
when called like this
Copy code
@Test
fun test() {
    val query = "convolutedExample"
    val expectedData = "[111111]"

    <http://testClient.post|testClient.post>()
        .uri(GRAPHQL_ENDPOINT)
        .accept(APPLICATION_JSON)
        .contentType(GRAPHQL_MEDIA_TYPE)
        .bodyValue("""query { $query(optListInput: [{
            |   number: 111111,
            |   }]
            |) }""".trimMargin())
        .exchange()
        .verifyData(query, expectedData)
}
Have I gone wrong somewhere or is this just too many generics deep for jackson to figure out?
d
that error indicates that jackson doesn't understand how to correctly parse the input
can you provide a small example that reproduces this error?
*it might be the issue with
OptionalInput
wrapper
yeah I think it is probably an issue with optional input and a list
m
I've reproduced it in graphql-kotlin by only adding those two snippets I sent. Would you like me to make a PR with the added test?
d
yeah PR would be great
👍 1
m
made the PR, first PR so forgive the stumbling around the whole process.
👍 1