This is a plugin for graphql-compose family, which adds to the ObjectTypeComposer pagination resolver.
Live demo: https://graphql-compose.herokuapp.com/
npm install graphql graphql-compose graphql-compose-pagination --saveModules graphql and graphql-compose are in peerDependencies, so should be installed explicitly in your app. They should not installed as sub-modules, cause internally checks the classes instances.
import { preparePaginationResolver } from 'graphql-compose-pagination';
import { UserTC, findManyResolver, countResolver } from './user';
const paginationResolver = preparePaginationResolver(UserTC, {
findManyResolver,
countResolver,
name: 'pagination', // Default
perPage: 20, // Default
});Implementation of findManyResolver and countResolver can be found in this file.
graphql-compose-mongoose – converts mongoose models to graphql types
