Skip to content

no-anonymous-operations

GraphQLsuspiciousno fixdefault: offgraphql/graphql-eslint-recommended

Reports an operation without a name ({ a }, query { a }).

Servers, logs, traces and caches identify an operation by its name. An anonymous one shows up as nothing in the query log, so it cannot be told from the others when something is slow or fails, and a persisted-query store has nothing to key it on.

To fix, name the operation: query GetA { a }.

Reported
query Named { a }
{ b }
query { c }
mutation ($x: Int) { d }
subscription S @live { e }
graphql:
lint:
rules:
no-anonymous-operations: warn # off (default), warn, error

Enabled by the presets: graphql/graphql-eslint-recommended.

Suppress one line with sudsy-disable-next-line no-anonymous-operations in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
graphql-eslint no-anonymous-operations full