mutation-payload-suffix

Since 0.9.0 · In the rulesets: Strict at error, All at error

This rule checks that the result types of mutation fields end with a suffix, Payload by default.

Rule details

Payload types are specific to their mutation; the suffix tells them from the domain types they contain. Scalar and enum results are not reported (see no-scalar-result-on-mutation).

The rule applies to definitions. An # apigenie-lint-disable mutation-payload-suffix 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 can be a string, the suffix, or an object with the suffix property.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        mutation-payload-suffix: [error, Result]

Examples

Good.

type Mutation { createUser(input: CreateUserInput!): CreateUserPayload }

Bad. The linter reports The result type 'User' of field 'Mutation.createUser' should end with 'Payload'.

type Mutation { createUser(input: CreateUserInput!): 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:
        mutation-payload-suffix: off

Related rules

Last updated on View as Markdown
Was this helpful?