Skip to content

useGraphqlNamedOperations (GraphQL)

Language GraphQL
biome.json
{
"linter": {
"rules": {
"correctness": {
"useGraphqlNamedOperations": "error"
}
}
}
}

Require a name for every explicit GraphQL operation definition.

Operation names help clients identify requests in logs, debugging tools, and caches. A name also distinguishes the operation from others in the same document.

The shorthand query form { field } has no operation-definition node and is not checked by this rule.

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{}
│ +++++
query Human {
name
}