Skip to content

no-name-underscore

Reports a name that starts or ends with an underscore: a type, field, argument, enum value, directive, operation, fragment or alias, and every reference to one. A field selected in a query is not reported (__typename).

Names that begin with two underscores are reserved for introspection, and one underscore is a mark that style guides use for private or generated names, which GraphQL has no concept of. A schema that avoids them has names that clients can use in generated code without escaping.

To fix, rename without the underscore.

Reported
scalar Good
scalar _Any
type Query {
items(first_: Int): [_Any!]!
_entities: Good
}
query Q { items(first_: 1) { __typename } }
graphql:
lint:
rules:
no-name-underscore: warn # off (default), warn, error

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

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

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
graphql-eslint naming-convention partial Leading and trailing underscores are no-name-underscore. No forbiddenPrefixes, forbiddenSuffixes, requiredPrefixes, requiredSuffixes or ignorePattern; no per-kind styles for the root types, interfaces versus objects, or inputs versus objects; PascalCase and camelCase accept runs of capitals (HTTPServer) that change-case rewrites.