so I have this class in kotlin:
@Component
class UserResolver @Autowired
constructor(private val userService: UserService): GraphQLMutationResolver, GraphQLQueryResolver {
fun createUser(user: User): User {
userService.save(user)
return user
}
fun users(): Page<User> {
val pageable = QPageRequest(0, 10)
return userService.all(pageable)
}
}
I want the method users to return Page object, I am completely new to graphql. I tried something like this:
type Page {
number: Int
size: Int
numberOfElements: Int
content: []
hasContent: Boolean
isFirst: Boolean
isLast: Boolean
hasNext: Boolean
hasPrevoius: Boolean
totalPages: Int
totalElements: Float
}
but my spring boot app is failing to start, I have no ideas what my schema definition for this class https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Page.html should look like. Does anyone have an idea?
Edit: error is:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.coxautodev.graphql.tools.SchemaParser]: Factory method 'schemaParser' threw exception; nested exception is com.coxautodev.graphql.tools.TypeClassMatcher$RawClassRequiredForGraphQLMappingException: Type org.springframework.data.domain.Page<sk.matusko.wixit.common.dao.User > cannot be mapped to a GraphQL type! Since GraphQL-Java deals with erased types at runtime, only non-parameterized classes can represent a GraphQL type. This allows for reverse-lookup by java class in interfaces and union types.