Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-connection-helper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-connection-helper

Create GraphQL Cursor Connections Spec compliant Objects the fly

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 26 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc