useLoneAnonymousOperation (GraphQL)
Language GraphQL
Summary
Section titled “Summary”- Rule available since:
v2.3.12 - Diagnostic Category:
lint/correctness/useLoneAnonymousOperation - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "correctness": { "useLoneAnonymousOperation": "error" } } }}Description
Section titled “Description”Disallow an anonymous operation in a document with other operations.
GraphQL allows the shorthand { field } without an operation name only when it is the sole
operation in the document. Name every operation when the document contains more than one.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”query { fieldA}
query B { fieldB}code-block.graphql:1:1 lint/correctness/useLoneAnonymousOperation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Document contains an anonymous operation while defining more than one operation. This anonymous operation must be the only defined operation in this document or turned into a named operation.
> 1 │ query {
│ ^^^^^^^
> 2 │ fieldA
> 3 │ }
│ ^
4 │
5 │ query B {
ℹ A GraphQL document that contains an anonymous operation (the query short-hand) is only valid if it contains only that one operation definition.
query A { fieldA}
query B { fieldB}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.