Linter rulesGraphQLrelay-connection-types
relay-connection-types
Since 0.9.0
This rule checks that connection types follow the Relay Cursor Connections specification.
Rule Details
Types named *Connection are object types with an edges field returning a list of edge types and a pageInfo: PageInfo! field. Object types that have both fields are named *Connection.
Configuration
This rule has no options.
version: "1.0"
commands:
lint:
graphql:
rules:
relay-connection-types: warning
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable relay-connection-types comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to definitions.
Examples
Good.
type Query {
users(first: Int, after: String, last: Int, before: String): UserConnection
}
interface Node { id: ID! }
type User implements Node { id: ID! }
type UserConnection { edges: [UserEdge], pageInfo: PageInfo! }
type UserEdge { node: User, cursor: String! }
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
Bad. The linter reports Connection type 'UserConnection' should have an 'edges' field returning a list of edges.
type UserConnection { users: [User] }