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

Marcus Dunn

03/29/2021, 6:15 PM
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

Dariusz Kuc

03/29/2021, 6:22 PM
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

Marcus Dunn

03/29/2021, 6:30 PM
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

Dariusz Kuc

03/29/2021, 6:31 PM
yeah PR would be great
👍 1
m

Marcus Dunn

03/29/2021, 7:26 PM
made the PR, first PR so forgive the stumbling around the whole process.
👍 1
27 Views