useUniqueGraphqlOperationName
¥Summary
-
规则生效日期:
v2.3.6¥Rule available since:
v2.3.6 -
诊断类别:
lint/nursery/useUniqueGraphqlOperationName¥Diagnostic Category:
lint/nursery/useUniqueGraphqlOperationName -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
灵感来自
@graphql-eslint/unique-operation-name¥Inspired from
@graphql-eslint/unique-operation-name
-
¥How to configure
{ "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
Biome v2.1 中文网 - 粤ICP备13048890号