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
edgesfield is considered by this spec to be an Edge type - Edge type must be an Object type
- Edge type must contain a field
nodethat 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
cursorthat 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
nodemust implementNodeinterface (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