Skip to content

Field mapped to Kotlin function reported as unmapped by SchemaMappingInspector #995

Closed
@sothawo

Description

@sothawo

I have the following schema:

type Author {
    id: ID!
    firstName: String!
    lastName: String!
    fullName: String!
    birthDate: Date!
}

This is implemented with a Kotlin data class like

data class Author(
    val id: String,
    val firstName: String,
    val lastName: String,
    val birthDate: LocalDate,
) {
    fun fullName(): String = "$firstName $lastName"
}

This works fine, I get the data in my GraphQL responses, but fullName is reported as unmapped field. For this simple case I can change that to a synthesized getter and the reporting is gone:

data class Author(
    val id: String,
    val firstName: String,
    val lastName: String,
    val birthDate: LocalDate,
) {
    val fullName get() = "$firstName $lastName"
}

But we have cases where we need the implementation as a function and cannot switch to a property.

Is there a possibility to recognize these fields as mapped?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions