Graphql Connection Helper
Easily create Graphql Cursor Connections for your model requests.
Install
npm i graphql-connection --save
or yarn add graphql-connection
usage
Right after querying your database / model, you can then simply...
import { GraphqlConnection } from 'graphql-connection';
const results = prisma.model.findMany({...})
const connection = getGraphQLConnection({
results,
before,
after,
first,
last
})
OPTIONS
GraphqlConnection's option object has only 5 options. All are optional except for the result field.
- results - an array of objects or type {id: string | number}[]
- before - before cursor of type string
- after - after cursor of type string
- first - pagination first of type number
- laste - pagination last of type number
- Both
before
and after
cursors are automatically encoded and decoded to base64