Created
November 3, 2017 02:02
-
-
Save jgcmarins/b0332b9a82fea2d0b24d6a3e626a9012 to your computer and use it in GitHub Desktop.
GraphQL UserConnection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { GraphQLInt } from 'graphql'; | |
import { connectionDefinitions } from 'graphql-relay'; | |
import UserType from '../type/user/UserType'; | |
export default connectionDefinitions({ | |
name: 'User', | |
nodeType: UserType, | |
connectionFields: () => ({ | |
totalCount: { | |
type: GraphQLInt, | |
resolve: connection => connection.count, | |
description: `A count of the total number of objects in this connection, ignoring pagination. | |
This allows a client to fetch the first five objects by passing "5" as the | |
argument to "first", then fetch the total count so it could display "5 of 83", | |
for example.`, | |
}, | |
}), | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment