relay-arguments
Since 0.9.0 · In the rulesets: All at error, Relay at error
This rule checks that fields returning connections take the pagination arguments of the Relay Cursor Connections specification.
Rule details
Forward pagination takes first: Int and after (String or a scalar), backward pagination last: Int and before. By default both pairs are required.
The rule applies to definitions. An # apigenie-lint-disable relay-arguments 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 includeBoth property: whether both pairs
of arguments are required (true by default) or one is enough.
version: "1.0"
commands:
lint:
graphql:
rules:
relay-arguments: [error, { includeBoth: 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 Field 'Query.users' returns a connection and should take the arguments first: Int, after: String, last: Int and before: String.
type Query { users: UserConnection }
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-arguments: off