Linter rulesGraphQLno-scalar-result-on-mutation

no-scalar-result-on-mutation

Since 0.9.0

This rule checks that mutation fields return object types rather than scalars.

Rule Details

A payload object can grow, e.g. with the changed objects or with errors, while a scalar result can only be replaced by a breaking change.

Configuration

This rule has no options.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        no-scalar-result-on-mutation: warning

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable no-scalar-result-on-mutation 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 { logout: LogoutPayload }
type LogoutPayload { success: Boolean }

Bad. The linter reports Field 'Mutation.logout' should return an object type rather than the scalar 'Boolean'.

type Mutation { logout: Boolean }

Related rules