useGraphqlNamedOperations
¥Summary
-
规则生效日期:
v2.0.0¥Rule available since:
v2.0.0 -
诊断类别:
lint/correctness/useGraphqlNamedOperations¥Diagnostic Category:
lint/correctness/useGraphqlNamedOperations -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "correctness": { "useGraphqlNamedOperations": "error" } } }}¥Description
强制要求指定 GraphQL 操作的名称。
¥Enforce specifying the name of GraphQL operations.
这很有用,因为大多数 GraphQL 客户端库都使用操作名称进行缓存。
¥This is useful because most GraphQL client libraries use the operation name for caching purposes.
¥Examples
¥Invalid
query {}code-block.graphql:1:1 lint/correctness/useGraphqlNamedOperations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━
✖ Anonymous GraphQL operations are forbidden. Make sure to name your query.
> 1 │ query {}
│ ^^^^^
2 │
ℹ Most GraphQL client libraries use the operation name for caching purposes.
ℹ Unsafe fix: Rename this query to Query.
1 │ query·Query{}
│ +++++
¥Valid
query Human { name}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号