useNamedOperation
Summary
Section titled Summary- Diagnostic Category:
lint/nursery/useNamedOperation
- This rule has an unsafe fix.
- The default severity of this rule is information.
- Sources:
- Same as
graphql/no-anonymous-operations
- Same as
Description
Section titled DescriptionEnforce specifying the name of GraphQL operations.
This is useful because most GraphQL client libraries use the operation name for caching purposes.
Examples
Section titled ExamplesInvalid
Section titled Invalidquery {}
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{}
│ +++++
Valid
Section titled Validquery Human { name}
How to configure
Section titled How to configure{ "linter": { "rules": { "nursery": { "useNamedOperation": "error" } } }}