Skip to content

Instantly share code, notes, and snippets.

@jgcmarins
Created November 3, 2017 02:02
Show Gist options
  • Save jgcmarins/b0332b9a82fea2d0b24d6a3e626a9012 to your computer and use it in GitHub Desktop.
Save jgcmarins/b0332b9a82fea2d0b24d6a3e626a9012 to your computer and use it in GitHub Desktop.
GraphQL UserConnection
// @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