1.1.4 • Published 2 years ago

graphql-connection-helper v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Continuous Integration

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';

// Incoming request with pagination fields (before, after,...

const results = prisma.model.findMany({...})

const connection = getGraphQLConnection({
  results,
  before,
  after,
  first,
  last
})
/**
 * returns {
 *  edges: {
 *    nodes: {
 *      ...
 *    }
 *  },
 *  pageInfo: {
 *    hasPreviousPage: ...
 *    hasNextPage: ...
 *    startCursor: ...
 *    endCursor: ...
 *  },
 *  totalCount
 * }
 * **/

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
1.1.4

2 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago