# relay-page-info

Source: https://api-genie.dev/docs/linter/graphql/rules/relay-page-info

A rule of the GraphQL linter, which reads GraphQL schemas and operations. Since 0.9.0. In the rulesets: All at error, Relay at error.

This rule checks that a schema with connections has a `PageInfo` type as the Relay Cursor Connections specification defines it.

## Rule details

`PageInfo` is an object type with the fields `hasNextPage: Boolean!`, `hasPreviousPage: Boolean!`, and the nullable `startCursor` and `endCursor` of type String or a scalar.

The rule applies to definitions. An `# apigenie-lint-disable relay-page-info` comment on a node
turns it off for the node and everything nested in it; at the top of the file, separated from the
first definition by a blank line, the comment turns it off for the whole file.

## Examples

**Good**.

```graphql
type Query {
  users(first: Int, after: String, last: Int, before: String): UserConnection
}
interface Node { id: ID! }
type User implements Node { id: ID! }
type UserConnection { edges: [UserEdge], pageInfo: PageInfo! }
type UserEdge { node: User, cursor: String! }
type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}
```

**Bad**. The linter reports `PageInfo should have a field 'hasNextPage: Boolean!'`.

```graphql
type UserConnection { edges: [UserEdge], pageInfo: PageInfo! }
type PageInfo { hasNextPage: Boolean }
```
