-
Notifications
You must be signed in to change notification settings - Fork 371
Closed
Labels
type: bugSomething isn't workingSomething isn't working
Description
Library Version
'org.http4k:http4k-graphql:4.33.1.0'
'com.expediagroup:graphql-kotlin-schema-generator:6.3.0'
Describe the bug
An error occurs when serializing a null as ID?
To Reproduce
import com.expediagroup.graphql.generator.TopLevelObject
import com.expediagroup.graphql.generator.scalars.ID
import com.expediagroup.graphql.generator.toSchema
import graphql.GraphQL
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
internal class GraphQlSerializationTest {
class Query {
fun getID(): ID? {
return null
}
}
private val topLevelObject = TopLevelObject(Query())
private val config = SchemaGeneratorConfig(listOf())
val schema = toSchema(config = config, queries = listOf(topLevelObject))
private val query = """
| query {
| getID
| }
|""".trimMargin()
@Test
fun `serializes nullable ID`() {
val graphQLResult = GraphQL
.newGraphQL(schema)
.build()
.execute(query)
graphQLResult.getData<Map<String,Any?>>()["getID"] shouldBe null
graphQLResult.errors shouldBe null
}
}
The above test fails as the second assertion fails with the following error.
Expected null but actual was [SerializationError{path=[getID], exception=graphql.schema.CoercingSerializeException: Expected type 'ID' but was 'ID'.}]
Expected behavior
GraphQL response should not contain serialization errors.
Metadata
Metadata
Assignees
Labels
type: bugSomething isn't workingSomething isn't working