Rules
Relay Edge Types

relay-edge-types

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

Set of rules to follow Relay specification for Edge types.

  • A type that is returned in list form by a connection type’s edges field is considered by this spec to be an Edge type
  • Edge type must be an Object type
  • Edge type must contain a field node that return either Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types. Notably, this field cannot return a list
  • Edge type must contain a field cursor that return either String, Scalar, or a non-null wrapper around one of those types
  • Edge type name must end in “Edge” (optional)
  • Edge type’s field node must implement Node interface (optional)
  • A list type should only wrap an edge type (optional)

Usage Examples

Correct

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

Config Schema

The schema defines the following properties:

withEdgeSuffix (boolean)

Edge type name must end in “Edge”.

Default: true

shouldImplementNode (boolean)

Edge type’s field node must implement Node interface.

Default: true

listTypeCanWrapOnlyEdgeType (boolean)

A list type should only wrap an edge type.

Default: true

Resources