useNamedOperation
Summary
Section titled “Summary”- Rule available since:
v2.0.0
- Diagnostic Category:
lint/nursery/useNamedOperation
- This rule has an unsafe fix.
- The default severity of this rule is error.
- Sources:
- Same as
graphql/no-anonymous-operations
- Same as
Description
Section titled “Description”Enforce specifying the name of GraphQL operations.
This is useful because most GraphQL client libraries use the operation name for caching purposes.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”query {}
code-block.graphql:1:1 lint/nursery/useNamedOperation 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}
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useNamedOperation": "error" } } }}