relayEdgeTypes
| Property | Value |
|---|---|
| Config name | relayEdgeTypes |
| Default severity | — |
| Context | Schema |
| In recommended | No |
What it checks
Section titled “What it checks”Enforces that edge types used by Relay connection types follow the Relay cursor connections specification. The rule identifies edge types by finding object types ending in Connection that have an edges list field, then validates the type returned by that field.
Specifically, edge types must have:
- A
nodefield that returns a named type (not a list) - A
cursorfield that returnsStringor a scalar type
Optionally, the rule also checks that:
- Edge type names end with
Edge(withEdgeSuffix) - The type returned by
nodeimplements theNodeinterface (shouldImplementNode) - List fields on connection types only wrap edge types (
listTypeCanWrapOnlyEdgeType)
This rule is not in the recommended preset because it’s specific to projects using Relay-style pagination.
Examples
Section titled “Examples”# ✅ Good — valid Relay edge typeinterface Node { id: ID!}
type User implements Node { id: ID! name: String!}
type UserEdge { node: User cursor: String!}
type UserConnection { edges: [UserEdge]}# ⚠️ Warning — edge type missing 'node' fieldtype UserEdge { cursor: String!}
type UserConnection { edges: [UserEdge]}# ⚠️ Warning — edge type missing 'cursor' fieldtype UserEdge { node: User}
type UserConnection { edges: [UserEdge]}# ⚠️ Warning — node field must not return a listtype UserEdge { node: [User] cursor: String!}
type UserConnection { edges: [UserEdge]}# ⚠️ Warning — edge type name should end with 'Edge'type UserItem { node: User cursor: String!}
type UserConnection { edges: [UserItem]}Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
withEdgeSuffix | boolean | true | Edge type names must end with Edge |
shouldImplementNode | boolean | true | The type returned by node must implement the Node interface |
listTypeCanWrapOnlyEdgeType | boolean | true | List fields on connection types may only wrap edge types |
Configuration
Section titled “Configuration”# Enable with defaultsextensions: graphql-analyzer: lint: rules: relayEdgeTypes: warn
# Disable the edge suffix requirementextensions: graphql-analyzer: lint: rules: relayEdgeTypes: [warn, { withEdgeSuffix: false }]
# Disable the Node interface checkextensions: graphql-analyzer: lint: rules: relayEdgeTypes: severity: warn options: shouldImplementNode: false
# Disable all optional checksextensions: graphql-analyzer: lint: rules: relayEdgeTypes: severity: warn options: withEdgeSuffix: false shouldImplementNode: false listTypeCanWrapOnlyEdgeType: false