relay-cursor-paging
Relay Cursor-Based Pagination Support for Sequelize
Last updated 4 years ago by darthtrevino .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install relay-cursor-paging 
SYNC missed versions from official npm registry.

Build Status

relay-cursor-paging

Relay Cursor-Based Pagination Support for Databases

API:

getPagingParameters(args): Emits an object with limit and criteria fields based on Relay's pagination fields (e.g. first, after, last, and before).

pageable(argSpec): Emits an augmented Argument Specification with first, after, before, and last arguments.

import { pageable, getPagingParameters } from "relay-cursor-paging";
const { connectionFromPromisedArraySlice } = require("graphql-relay");

const myType = new GraphQLObjectType({
    fields: () => {  
        relatedThings: {      
            type: thingConnection,
            args: pageable({}), // Adds first, after, last, and before arguments
            resolve: (root, args) => {
                const { limit, offset } = getPagingParameters(args);                
                const criteria = makeCriteria(args, limit, offset);
                                                            
                return connectionFromPromisedArraySlice(
                    thingRepository.findAll(criteria),
                    args, 
                    {
                        sliceStart: 0,
                        arrayLength: // count query result
                    }
                );
            }
        }
    }
});

Current Tags

  • 0.2.0                                ...           latest (4 years ago)

8 Versions

  • 0.2.0                                ...           4 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 2
Dependencies (1)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |