Skip to content

useUniqueGraphqlOperationName

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"useUniqueGraphqlOperationName": "error"
}
}
}
}

¥Description

强制 GraphQL 文档中的操作名称必须唯一。

¥Enforce unique operation names across a GraphQL document.

此规则确保所有 GraphQL 操作(查询、变更、订阅)都具有唯一名称。使用唯一的操作名称对于正确识别和减少混淆至关重要。

¥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.

¥Examples

¥Invalid

query user {
user {
id
}
}
query user {
me {
id
}
}
code-block.graphql:7:1 lint/nursery/useUniqueGraphqlOperationName ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Operation named “user” is already defined.

5 │ }
6 │
> 7 │ query user {
^^^^^^^^^^^^
> 8 │ me {
> 9 │ id
> 10 │ }
> 11 │ }
^
12 │

GraphQL operation names must be unique to ensure proper identification.

Rename the operation to have a unique name.

¥Valid

query user {
user {
id
}
}
query me {
me {
id
}
}

¥Related links