Rules
Relay Arguments

relay-arguments

  • Category: Schema
  • Rule name: @graphql-eslint/relay-arguments
  • Requires GraphQL Schema: false ℹ️
  • Requires GraphQL Operations: false ℹ️

Set of rules to follow Relay specification for Arguments.

  • A field that returns a Connection type must include forward pagination arguments (first and after), backward pagination arguments (last and before), or both

Forward pagination arguments

  • first takes a non-negative integer
  • after takes the Cursor type

Backward pagination arguments

  • last takes a non-negative integer
  • before takes the Cursor type

Usage Examples

Incorrect

# eslint @graphql-eslint/relay-arguments: 'error'
 
type User {
  posts: PostConnection
}

Correct

# eslint @graphql-eslint/relay-arguments: 'error'
 
type User {
  posts(after: String, first: Int, before: String, last: Int): PostConnection
}

Config Schema

The schema defines the following properties:

includeBoth (boolean)

Enforce including both forward and backward pagination arguments

Default: true

Resources