useGraphqlNamedOperations (GraphQL)
Language GraphQL
Summary
Section titled “Summary”- Rule available since:
v2.0.0 - Diagnostic Category:
lint/correctness/useGraphqlNamedOperations - This rule is recommended, meaning it is enabled by default.
- This rule has an unsafe fix.
- The default severity of this rule is error.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "correctness": { "useGraphqlNamedOperations": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “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{}
│ +++++
query Human { name}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.