Hello, I am trying to implement some basic paginat...
# graphql-kotlin
d
Hello, I am trying to implement some basic pagination and it seems like I should be using generics, but that doesn’t generate graphql schema:
Copy code
com.expediagroup.graphql.exceptions.TypeNotSupportedException: Cannot convert T since it is not a valid GraphQL type or outside the supported packages
Code:
Copy code
class MyQuery: Query {}
    suspend fun students(pageNumber:Int): Page<Student> {
      return getStudents(pageNumber)
    } 
}
data class Page<T>(val items: List<T>, pageNumber: Int)
data class Student(val name: String)
Is there a recommended way to design this?
d
Hello đź‘‹ TLDR generics are not supported by GraphQL spec so we don't support it either (https://github.com/ExpediaGroup/graphql-kotlin/issues/292)
While it is not ideal, the workaround is to create specific
Page
flavors (i.e.
StudentPage
instead of generic
Page<T>
)
d
Yeah, that’s what I thought so. Thank you Dariusz.