Skip to content

noRootType (GraphQL)

Language GraphQL
biome.json
{
"linter": {
"rules": {
"style": {
"noRootType": "error"
}
}
}
}

Disallow configured GraphQL root operation types.

A schema uses the Query, Mutation, and Subscription root types as entry points. This rule can forbid root types that a project does not support. It does nothing until at least one type is listed in the disallow option.

biome.json
{
"linter": {
"rules": {
"style": {
"noRootType": {
"level": "on",
"options": {
"disallow": [
"mutation"
]
}
}
}
}
}
}
type Mutation {
createUser(input: CreateUserInput!): User!
}
code-block.graphql:1:6 lint/style/noRootType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This schema defines the disallowed root type Mutation.

> 1 │ type Mutation {
│ ^^^^^^^^
2 │ createUser(input: CreateUserInput!): User!
3 │ }

ℹ This project forbids that root type to enforce a specific schema design.

ℹ Use a different root type, or update the rule configuration if this root type should be allowed.

type Query {
users: [User!]!
}

Lists root types to disallow, without regard to letter case. Defaults to an empty list.

biome.json
{
"linter": {
"rules": {
"style": {
"noRootType": {
"level": "on",
"options": {
"disallow": [
"subscription"
]
}
}
}
}
}
}
type Subscription {
user: User
}
code-block.graphql:1:6 lint/style/noRootType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This schema defines the disallowed root type Subscription.

> 1 │ type Subscription {
│ ^^^^^^^^^^^^
2 │ user: User
3 │ }

ℹ This project forbids that root type to enforce a specific schema design.

ℹ Use a different root type, or update the rule configuration if this root type should be allowed.