graphql-compose-pagination
This is a plugin for graphql-compose family, which adds to the ObjectTypeComposer pagination
resolver.
Live demo: https://graphql-compose.herokuapp.com/
Installation
npm install graphql graphql-compose graphql-compose-pagination --save
Modules graphql
and graphql-compose
are in peerDependencies
, so should be installed explicitly in your app. They should not installed as submodules, cause internally checks the classes instances.
Example
import composeWithPagination from 'graphql-compose-pagination';
import userTypeComposer from './user.js';
composeWithPagination(userTypeComposer, {
findResolverName: 'findMany',
countResolverName: 'count',
});
Requirements
Types should have following resolvers:
count
- for records countfindMany
- for filtering records. ResolverfindMany
should havelimit
andskip
args.
Used in plugins
graphql-compose-mongoose - converts mongoose models to graphql types