Skip to Content
🚧 This is WIP documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Rulesrelay-connection-types

relay-connection-types

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

Set of rules to follow Relay specification for Connection types.

  • Any type whose name ends in “Connection” is considered by spec to be a Connection type
  • Connection type must be an Object type
  • Connection type must contain a field edges that return a list type that wraps an edge type
  • Connection type must contain a field pageInfo that return a non-null PageInfo Object type

Usage Examples

Incorrect

# eslint @graphql-eslint/relay-connection-types: 'error'
 
type UserPayload { # should be an Object type with `Connection` suffix
  edges: UserEdge! # should return a list type
  pageInfo: PageInfo # should return a non-null `PageInfo` Object type
}

Correct

# eslint @graphql-eslint/relay-connection-types: 'error'
 
type UserConnection {
  edges: [UserEdge]
  pageInfo: PageInfo!
}

Resources

Last updated on