🔗 GraphQL Connection Resolver
Helps to easily implement the relay connection specification (inspired by Nexus.js Connection Plugin)
Connection
?
What is the
Install
$ yarn add graphql-connection-resolver
Example
Schema
scalar DateTime type Query { chatRoom(id: String!): ChatRoom} type ChatRoom { id: ID! # if messages empty, returns null messages( first: Int last: Int before: Int after: Int ): ChatMessageConnection!} type ChatMessage { id: ID! createdAt: DateTime!} type ChatMessageConnection { edges: [ChatMessageEdge!]! pageInfo: PageInfo!} type ChatMessageEdge { node: ChatMessage! cursor: String!} type PageInfo { hasPreviousPage: Boolean! hasNextPage: Boolean! startCursor: String endCursor: String}
Resolver
Note
-
You must request one more than given by first and last. Inside the library, if nodes return the same number as the given
first
orlast
, the next page is considered to not exist, and if nodes return more than the given number, the next page is considered to exist.connection
References
If you have a feature request or a bug, please create a new issue. And also, pull requests are always welcome 🙏