Back to Biomejs

noRootType

src/content/docs/linter/rules/no-root-type.mdx

latest2.2 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="GraphQL" icon="seti:graphql"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.12` - Diagnostic Category: [`lint/nursery/noRootType`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`@graphql-eslint/no-root-type`](https://the-guild.dev/graphql/eslint/rules/no-root-type)

How to configure

json
{
	"linter": {
		"rules": {
			"nursery": {
				"noRootType": "error"
			}
		}
	}
}

Description

Disallow the usage of specified root types

Prevent the usage of certain root types (e.g. mutation and/or subscription)

Examples

Invalid

json
{
	"linter": {
		"rules": {
			"nursery": {
				"noRootType": {
					"options": {
						"disallow": [
							"mutation"
						]
					}
				}
			}
		}
	}
}

graphql
type Mutation {
  createUser(input: CreateUserInput!): User!
}
<pre class="language-text"><code class="language-text"></code></pre>

Valid

graphql
type Query {
  users: [User!]!
}

Options

disallow

This required option lists all disallowed root types (e.g. mutation and/or subscription). The values of the list are case-insensitive.

Default []

json
{
	"linter": {
		"rules": {
			"nursery": {
				"noRootType": {
					"options": {
						"disallow": [
							"subscription"
						]
					}
				}
			}
		}
	}
}

graphql
type Subscription {
  user: User
}
<pre class="language-text"><code class="language-text"></code></pre> </TabItem> </Tabs>