pageInfoGraphQLType top-level property

GraphQLObjectType<PageInfo> pageInfoGraphQLType
final

GraphQLType with the state of pagination

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

Implementation

final pageInfoGraphQLType = objectType<PageInfo>(
  'PageInfo',
  description: 'Information about pagination in a connection.',
  fields: [
    graphQLBoolean.nonNull().field(
      'hasNextPage',
      description: 'When paginating forwards, are there more items?',
      resolve: (pageInfo, _) {
        return pageInfo.hasNextPage;
      },
    ),
    graphQLBoolean.nonNull().field(
      'hasPreviousPage',
      description: 'When paginating backwards, are there more items?',
      resolve: (pageInfo, _) {
        return pageInfo.hasPreviousPage;
      },
    ),
    graphQLString.field(
      'startCursor',
      description: 'When paginating backwards, the cursor to continue.',
      resolve: (pageInfo, _) {
        return pageInfo.startCursor;
      },
    ),
    graphQLString.field(
      'endCursor',
      description: 'When paginating forwards, the cursor to continue.',
      resolve: (pageInfo, _) {
        return pageInfo.endCursor;
      },
    ),
  ],
);