pgutkowski / KGraphQL

Pure Kotlin GraphQL implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scalar types within variables not working

jeggy opened this issue · comments

It's failing when trying to use scalar types within variables. See example below.

// This test should be in `ScalarsSpecificationTest`
@Test
fun `Scalars within input variables`(){
    val schema = KGraphQL.schema {
        floatScalar<Dob> {
            deserialize = ::Dob
            serialize = { (double) -> double }
        }

        query("double"){
            resolver { double : Dob -> double }
        }
    }

    val value = 232.33
    val response = deserialize(schema.execute(
        request = "query customQuery(\$var: Dob!){double(double: \$var)}",
        variables = "{\"var\": $value}"
    ))
    assertThat(response.extract<Double>("data/double"), equalTo(value))
}

Gives:

com.github.pgutkowski.kgraphql.ExecutionException: Failed to coerce 232.33 as com.github.pgutkowski.kgraphql.specification.typesystem.ScalarsSpecificationTest.Dob

Your fix will be included in 0.3.1, planned to be relased today.