The porpose of this repo is to both serve as an incubator for an offset pagination library and to showcase its usage
Page arguments ( like pageNumber and pageSize ) are passed as arguments to the query. Those are then resolved by the library and the result is returned as a PageRequest object.
In the query one uses:
query {
examplePaged(pageNumber:5 , pageSize: 10){
}
}
Then in the controller one receives:
@QueryMapping("examplePaged")
public Page<Example> paged(PageRequest pageRequest) {
return exampleRepository.findPage(
pageRequest
);
}
For this to be possible, I implemented a TypeDefinitionConfigurer( PageTypeDefinitionConfigurer ) that adds the necessary fields to the schema. Also, A HandlerMethodArgumentResolver ( PageRequestHandlerMethodArgumentResolver ) was implemented to resolve the PageRequest object from the query arguments ( pageSize and pageNumber).