I'm trying to make a pagination with mongose and graphql very similar to google (numeric type). But the results I have are not what I expected. The limit works and I think the offset also but I am trying to get the current page and the number of pages and it is not reaching me. I am using mongose pagginate v2 and in its doc it says that I can live all those values of the result.
-----Resolver Query----
const Product = require('../models/Product');
async function pagProducts(root, args){
console.log(args.page)
const query = Product.find({});
const options = {
page: args.page,
offset: args.offset,
limit: args.limit,
}
await Product.paginate(query, options).then(function(result) {
console.log(result)/*Here I only get an array with the objects, the total of docs the limit and the offset but nothing of the current page and pages*/
})
}
module.exports = {
pagProducts
}
--------Schema.graphql
type Product{
_id: String
title: String!
price: Float
unitydetail: String
unityForPound: Int
}
type Query {
pagProducts(offset: Int, limit: Int, page: Int):[Product]
}