aPureBase / KGraphQL

Pure Kotlin GraphQL implementation
https://kgraphql.io
MIT License
298 stars 58 forks source link

Enum arrays within variables crashes #135

Closed jeggy closed 3 years ago

jeggy commented 3 years ago

This example:

@Test
fun `query with enum array variables`() {
    val schema = defaultSchema {
        enum<FilmType>()
        query("search") {
            description = "film categorized by type"
            resolver { types: List<FilmType> ->
                "You searched for: ${types.joinToString { it.name }}"
            }
        }
    }

    val map = schema.executeBlocking(
        request = "query Search(${'$'}types: [FilmType!]!) { search(types: ${'$'}types)}",
        variables = "{\"types\":[\"FULL_LENGTH\"]}"
    ).deserialize()

    assertNoErrors(map)
    assertThat(map.extract<String>("data/search"), equalTo("You searched for: FULL_LENGTH"))
}

Throws this error: com.apurebase.kgraphql.GraphQLError: class java.lang.String cannot be cast to class com.apurebase.kgraphql.FilmType (java.lang.String is in module java.base of loader 'bootstrap'; com.apurebase.kgraphql.FilmType is in unnamed module of loader 'app')