Back to Biomejs

GraphQL Rules

src/content/docs/linter/graphql/rules.mdx

latest4.9 KB
Original Source

import { Icon } from "@astrojs/starlight/components";

Below the list of rules supported by Biome, divided by group. Here's a legend of the emojis:

  • The icon <span class='inline-icon' title="This rule is recommended"><Icon name="approve-check-circle" label="This rule is recommended" /></span> indicates that the rule is part of the recommended rules.
  • The icon <span class='inline-icon' title="This rule has a safe fix"><Icon name="seti:config" label="The rule has a safe fix" /></span> indicates that the rule provides a code action (fix) that is safe to apply.
  • The icon <span class='inline-icon' title="This rule has an unsafe fix"><Icon name="warning" label="The rule has an unsafe fix" /></span> indicates that the rule provides a code action (fix) that is unsafe to apply.
  • The icon <span class='inline-icon' title="This rule is not released yet"><Icon name="moon" label="This rule is not released yet" /></span> indicates that the rule has been implemented and scheduled for the next release.

correctness

Rule nameDescriptionProperties
useGraphqlNamedOperationsEnforce specifying the name of GraphQL operations.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>

nursery

Rule nameDescriptionProperties
noDuplicateArgumentNamesRequire all argument names for fields & directives to be unique.
noDuplicateEnumValueNamesRequire all enum value names to be unique.
noDuplicateFieldDefinitionNamesRequire all fields of a type to be unique.
noDuplicateGraphqlOperationNameEnforce unique operation names across a GraphQL document.
noDuplicateInputFieldNamesRequire fields within an input object to be unique.
noDuplicateVariableNamesRequire all variable definitions to be unique.
noExcessiveLinesPerFileRestrict the number of lines in a file.
noRootTypeDisallow the usage of specified root types
useConsistentGraphqlDescriptionsRequire all descriptions to follow the same style (either block or inline) to maintain consistency and improve readability across the schema.
useInputNameRequire mutation argument to be always called "input"
useLoneAnonymousOperationDisallow anonymous operations when more than one operation specified in document.
useLoneExecutableDefinitionRequire queries, mutations, subscriptions or fragments each to be located in separate files.

style

Rule nameDescriptionProperties
useDeprecatedReasonRequire specifying the reason argument when using @deprecated directive<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useGraphqlNamingConventionValidates that all enum values are capitalized.

suspicious

Rule nameDescriptionProperties
noDuplicateFieldsNo duplicated fields in GraphQL operations.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noEmptySourceDisallow empty sources.
useDeprecatedDateRequire the @deprecated directive to specify a deletion date.

Missing a rule? Help us by contributing to the analyzer or create a rule suggestion here.