Linter rulesGraphQLno-root-type
no-root-type
Since 0.9.0
This rule checks that the schema doesn’t have the root operation types the configuration disallows.
Rule Details
Some APIs are read-only, or don’t support subscriptions. The rule reports the disallowed root operation types; with the default configuration it reports nothing.
Configuration
The configuration block is an object with the disallow property: a list of mutation
and subscription.
version: "1.0"
commands:
lint:
graphql:
rules:
no-root-type: [error, { disallow: [mutation, subscription] }]
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable no-root-type 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 Query { me: User }
Bad. With the options { disallow: [mutation] }, the linter reports The schema should not have a mutation root operation type ('Mutation').
type Query { me: User }
type Mutation { logout: Boolean }