Skip to content

Edge

The @edge directive marks an object type as a Relay Edge type, representing an item within a paginated connection.

Purpose

Use @edge to identify types that wrap nodes in a connection with cursor information. This enables:

  • Build-time validation of edge type structure
  • Integration with Viaduct's pagination utilities
  • Clear schema documentation of pagination patterns

Schema definition

The directive is defined in Viaduct's default schema:

"Marks an object type as a Relay Edge type"
directive @edge on OBJECT

Usage

Apply @edge to object types within connections:

"""
An edge in a CharactersConnection.
"""
type CharacterEdge @edge @scope(to: ["default"]) {
  "The character at the end of the edge"
  node: Character
  "A cursor for pagination"
  cursor: String!
}

View full file on GitHub

Here's another edge example from the Films connection:

"""
An edge in a Films connection.
Demonstrates usage of @edge directive.
"""
type FilmEdge @edge @scope(to: ["default"]) {
  "The item at the end of the edge."
  node: Film
  "A cursor for use in pagination."
  cursor: String!
}

View full file on GitHub

Requirements

Types marked with @edge must:

  1. Have a node field (any output type except list)
  2. Have a cursor: String! field (non-nullable String)

Note

Full validation and builder utilities are under development. See the Pagination guide for more details.