Linter rulesGraphQLmutation-payload-suffix

mutation-payload-suffix

Since 0.9.0

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).

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]

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable mutation-payload-suffix 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 }

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

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

Related rules