Back to Biomejs

noDuplicateInputFieldNames

src/content/docs/linter/rules/no-duplicate-input-field-names.mdx

latest4.5 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.11` - Diagnostic Category: [`lint/nursery/noDuplicateInputFieldNames`](/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/unique-input-field-names`](https://the-guild.dev/graphql/eslint/rules/unique-input-field-names)

How to configure

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

Description

Require fields within an input object to be unique.

A GraphQL input object value is only valid if all supplied fields are uniquely named.

Examples

Invalid

graphql
query {
  field(arg: { f1: "value", f1: "value" })
}
<pre class="language-text"><code class="language-text">code-block.graphql:2:14 <a href="https://biomejs.dev/linter/rules/no-duplicate-input-field-names">lint/nursery/noDuplicateInputFieldNames</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Duplicate input field name.</span> <strong>1 │ </strong>query &#123; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> field(arg: &#123; f1: &quot;value&quot;, f1: &quot;value&quot; &#125;) <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>3 │ </strong>&#125; <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">A GraphQL input object value is only valid if all supplied fields are uniquely named. Make sure to name every input field differently.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span> </code></pre>

Valid

graphql
query {
  field(arg: { f1: "value", f2: "value" })
}
</TabItem> </Tabs>