Skip to content

useGraphqlNamedOperations

¥Summary

¥How to configure

biome.json
{
"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