- Category:
Schema & Operations
- Rule name:
@graphql-eslint/alphabetize
- Requires GraphQL Schema:
false
ℹ️ - Requires GraphQL Operations:
false
ℹ️
Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation selections and more.
# eslint @graphql-eslint/alphabetize: ['error', { fields: ['ObjectTypeDefinition'] }]
type User {
password: String
firstName: String! # should be before "password"
age: Int # should be before "firstName"
lastName: String!
}
# eslint @graphql-eslint/alphabetize: ['error', { fields: ['ObjectTypeDefinition'] }]
type User {
age: Int
firstName: String!
lastName: String!
password: String
}
# eslint @graphql-eslint/alphabetize: ['error', { values: ['EnumTypeDefinition'] }]
enum Role {
SUPER_ADMIN
ADMIN # should be before "SUPER_ADMIN"
USER
GOD # should be before "USER"
}
# eslint @graphql-eslint/alphabetize: ['error', { values: ['EnumTypeDefinition'] }]
enum Role {
ADMIN
GOD
SUPER_ADMIN
USER
}
# eslint @graphql-eslint/alphabetize: ['error', { selections: ['OperationDefinition'] }]
query {
me {
firstName
lastName
email # should be before "lastName"
}
}
# eslint @graphql-eslint/alphabetize: ['error', { selections: ['OperationDefinition'] }]
query {
me {
email
firstName
lastName
}
}
The schema defines the following properties:
Fields of type
, interface
, and input
The elements of the array can contain the following enum values:
ObjectTypeDefinition
InterfaceTypeDefinition
InputObjectTypeDefinition
Additional restrictions:
- Minimum items:
1
- Unique items:
true
Values of enum
The elements of the array can contain the following enum values:
EnumTypeDefinition
Additional restrictions:
- Minimum items:
1
- Unique items:
true
Selections of operations (query
, mutation
and subscription
) and fragment
The elements of the array can contain the following enum values:
OperationDefinition
FragmentDefinition
Additional restrictions:
- Minimum items:
1
- Unique items:
true
Variables of operations (query
, mutation
and subscription
)
The elements of the array can contain the following enum values:
OperationDefinition
Additional restrictions:
- Minimum items:
1
- Unique items:
true
Arguments of fields and directives
The elements of the array can contain the following enum values:
FieldDefinition
Field
DirectiveDefinition
Directive
Additional restrictions:
- Minimum items:
1
- Unique items:
true