Linter rulesGraphQLmutation-input-argument
mutation-input-argument
Since 0.9.0
This rule checks that mutation fields take a single argument, input, of a non-null input object type.
Rule Details
A single input object can evolve without breaking clients: fields are added to the input type rather than as new arguments of the mutation. Mutations without arguments are not reported.
Configuration
The configuration block is an object with the properties:
argumentName: the name of the argument,inputby defaultrequireNonNull: whether the argument must be non-null,trueby default
version: "1.0"
commands:
lint:
graphql:
rules:
mutation-input-argument: [error, { argumentName: data, requireNonNull: false }]
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable mutation-input-argument 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 Mutation { createUser(input: CreateUserInput!): CreateUserPayload }
input CreateUserInput { name: String }
Bad. The linter reports Field 'Mutation.createUser' should take a single argument named 'input'.
type Mutation { createUser(name: String, email: String): CreateUserPayload }