---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useUniqueGraphqlOperationName
description: Learn more about useUniqueGraphqlOperationName
---
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.6`
- Diagnostic Category: [`lint/nursery/useUniqueGraphqlOperationName`](/reference/diagnostics#diagnostic-category)
- This rule doesn't have a fix.
- The default severity of this rule is [**information**](/reference/diagnostics#information).
- Sources: 
  - Inspired from [`@graphql-eslint/unique-operation-name`](https://the-guild.dev/graphql/eslint/rules/unique-operation-name)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"nursery": {
				"useUniqueGraphqlOperationName": "error"
			}
		}
	}
}

```
## Description
Enforce unique operation names across a GraphQL document.

This rule ensures that all GraphQL operations (queries, mutations, subscriptions) have unique names.
Using unique operation names is essential for proper identification and reducing confusion.

:::note
This rule currently does not work across multiple files.
:::

## Examples

### Invalid

```graphql
query user {
  user {
    id
  }
}

query user {
  me {
    id
  }
}
```

<pre class="language-text"><code class="language-text">code-block.graphql:7:1 <a href="https://biomejs.dev/linter/rules/use-unique-graphql-operation-name">lint/nursery/useUniqueGraphqlOperationName</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Operation named &quot;user&quot; is already defined.</span><br />  <br />     <strong>5 │ </strong>&#125;<br />     <strong>6 │ </strong><br />   <strong><span style="color: Tomato;">&gt;</span></strong> <strong>7 │ </strong>query user &#123;<br />    <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><br />   <strong><span style="color: Tomato;">&gt;</span></strong> <strong>8 │ </strong>  me &#123;<br />   <strong><span style="color: Tomato;">&gt;</span></strong> <strong>9 │ </strong>    id<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>10 │ </strong>  &#125;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>11 │ </strong>&#125;<br />    <strong>   │ </strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>12 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">GraphQL operation names must be unique to ensure proper identification.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Rename the operation to have a unique name.</span><br />  <br />  <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><br />  <br /></code></pre>

### Valid

```graphql
query user {
  user {
    id
  }
}

query me {
  me {
    id
  }
}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_graphql_analyze/src/lint/nursery/use_unique_graphql_operation_name.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_graphql_analyze/tests/specs/nursery/useUniqueGraphqlOperationName)

</TabItem>
</Tabs>