relay-edge-types
Since 0.9.0 · In the rulesets: All at error, Relay at error
This rule checks that the edge types of connections follow the Relay Cursor Connections specification.
Rule details
The edge types returned by the edges field of connection types are object types with a node field that is not a list and a cursor field of type String or a scalar.
The rule applies to definitions. An # apigenie-lint-disable relay-edge-types comment on a node
turns it off for the node and everything nested in it; at the top of the file, separated from the
first definition by a blank line, the comment turns it off for the whole file.
Configuration
The configuration block is an object with the boolean properties:
withEdgeSuffix: edge type names end withEdge;trueby defaultshouldImplementNode: the object types of nodes implement theNodeinterface;trueby defaultlistTypeCanWrapOnlyEdgeType: the list fields of connection types return edge types;falseby default
version: "1.0"
commands:
lint:
graphql:
rules:
relay-edge-types: [error, { shouldImplementNode: false }]
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 Edge type 'UserEdge' should have a 'node' field that is not a list.
type UserConnection { edges: [UserEdge], pageInfo: PageInfo! }
type UserEdge { node: [User] }
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.
commands:
lint:
graphql:
rules:
relay-edge-types: off