✅ The "extends": "plugin:@graphql-eslint/schema-recommended"
and "plugin:@graphql-eslint/operations-recommended"
property in a configuration file enables this rule.
- Category:
Schema & Operations
- Rule name:
@graphql-eslint/naming-convention
- Requires GraphQL Schema:
false
ℹ️ - Requires GraphQL Operations:
false
ℹ️
Require names to follow specified conventions.
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
type user {
first_name: String!
}
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
fragment UserFragment on User {
# ...
}
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
type Query {
getUsers: [User!]!
}
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
type User {
firstName: String
}
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
fragment UserFields on User {
# ...
}
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
type Query {
users: [User!]!
}
# eslint @graphql-eslint/naming-convention: ['error', { FieldDefinition: { style: 'camelCase', ignorePattern: '^(EAN13|UPC|UK)' } }]
type Product {
EAN13: String
UPC: String
UKFlag: String
}
It's possible to use a
selector
that starts with allowedASTNode
names which are described below.Paste or drop code into the editor in ASTExplorer and inspect the generated AST to compose your selector.
Example: pattern property
FieldDefinition[parent.name.value=Query]
will match only fields for typeQuery
.
The schema defines the following properties:
Includes:
ObjectTypeDefinition
InterfaceTypeDefinition
EnumTypeDefinition
ScalarTypeDefinition
InputObjectTypeDefinition
UnionTypeDefinition
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asString
asObject
Default: false
Default: false
The schema defines the following additional types:
One of: camelCase
, PascalCase
, snake_case
, UPPER_CASE
Properties of the asObject
object:
This element must be one of the following enum values:
camelCase
PascalCase
snake_case
UPPER_CASE
The object is an array with all elements of the type string
.
Additional restrictions:
- Minimum items:
1
- Unique items:
true
The object is an array with all elements of the type string
.
Additional restrictions:
- Minimum items:
1
- Unique items:
true
Option to skip validation of some words, e.g. acronyms