relay-mongodb-connection
Like
connectionFromArray()
but for MongoDB cursors
Install
npm install --save relay-mongodb-connection
Usage
Give it a cursor from mongodb, and it handles pagination int he same way graphql-relay does for arrays.
;
Also supports mongoose's querys and aggregations.
;;
At a glance
Pass it a MongoDB cursor and connectionArgs
, and it's happy.
{ return ;}
Optionally give it a mapper function:
{ return ;}
And for Mongoose users:
{ return ;}
Example
// ...;// ... // Instead of resolving, synchronously returns a MongoDB Cursor. { return db;} const GraphQLUser = name: 'User' fields: id: spaceships: type: SpaceshipConnection args: ...connectionArgs { const spaceshipCursor = ; return ; } ;
connectionFromMongoCursor
automatically skips and limits the MongoDB Cursor so that only the necessary documents are retrieved from the database.
Changelog
See CHANGELOG.md
Testing
MONGO_URL=mongodb://192.168.99.100/mongodbconnection npm test
License
MIT © Mikael Berg