---
# 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: useGraphqlNamedOperations
description: Learn more about useGraphqlNamedOperations
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="GraphQL" icon="seti:graphql">
## Summary
- Rule available since: `v2.0.0`
- Diagnostic Category: [`lint/correctness/useGraphqlNamedOperations`](/reference/diagnostics#diagnostic-category)
- This rule is **recommended**, meaning it is enabled by default.
- This rule has an [**unsafe**](/linter/#unsafe-fixes) fix.
- The default severity of this rule is [**error**](/reference/diagnostics#error).
- Sources: 
  - Same as [`@graphql-eslint/no-anonymous-operations`](https://the-guild.dev/graphql/eslint/rules/no-anonymous-operations)

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

```
## Description
Enforce specifying the name of GraphQL operations.

This is useful because most GraphQL client libraries use the operation name for caching purposes.

## Examples

### Invalid

```graphql
query {}
```

<pre class="language-text"><code class="language-text">code-block.graphql:1:1 <a href="https://biomejs.dev/linter/rules/use-graphql-named-operations">lint/correctness/useGraphqlNamedOperations</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Anonymous GraphQL operations are forbidden. Make sure to name your query.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>query &#123;&#125;<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><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Most GraphQL client libraries use the operation name for caching purposes.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Rename this query to Query.</span><br />  <br />  <strong>  1 │ </strong>query<span style="opacity: 0.8;">·</span><span style="color: MediumSeaGreen;">Q</span><span style="color: MediumSeaGreen;">u</span><span style="color: MediumSeaGreen;">e</span><span style="color: MediumSeaGreen;">r</span><span style="color: MediumSeaGreen;">y</span>&#123;&#125;<br />  <strong>    │ </strong>      <span style="color: MediumSeaGreen;">+</span><span style="color: MediumSeaGreen;">+</span><span style="color: MediumSeaGreen;">+</span><span style="color: MediumSeaGreen;">+</span><span style="color: MediumSeaGreen;">+</span>  <br /></code></pre>

### Valid

```graphql
query Human {
  name
}
```

## 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/correctness/use_graphql_named_operations.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_graphql_analyze/tests/specs/correctness/useGraphqlNamedOperations)

</TabItem>
</Tabs>