# relay-arguments

Source: https://apigenie.pl/docs/linter/graphql/rules/relay-arguments

This rule checks that fields returning connections take the pagination arguments of the Relay Cursor Connections specification.

## Rule Details

Forward pagination takes `first: Int` and `after` (String or a scalar), backward pagination `last: Int` and `before`. By default both pairs are required.

## Configuration

The configuration block is an object with the `includeBoth` property: whether both pairs
of arguments are required (`true` by default) or one is enough.

```yaml
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        relay-arguments: [error, { includeBoth: false }]
```

The rule can be disabled for a node and everything nested in it with an `# apigenie-lint-disable relay-arguments` comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to definitions.

## 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 `Field 'Query.users' returns a connection and should take the arguments first: Int, after: String, last: Int and before: String`.

```graphql
type Query { users: UserConnection }
```
