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:
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!
}
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!
}
Requirements¶
Types marked with @edge must:
- Have a
nodefield (any output type except list) - Have a
cursor: String!field (non-nullable String)
Note
Full validation and builder utilities are under development. See the Pagination guide for more details.
Related¶
@connectiondirective - Mark connection types- Pagination guide - Complete pagination documentation
- Relay Connection Specification - The specification this implements