Skip to content

useSortedTypeFields (GraphQL)

Language GraphQL
.vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.action.useSortedTypeFields.biome": "explicit",
"source.fixAll.biome": "explicit"
}
}
biome.json
{
"assist": {
"actions": {
"source": {
"useSortedTypeFields": "on"
}
}
}
}

Sort fields in GraphQL type definitions alphabetically.

This rule ensures that fields within type, interface, and input definitions are sorted alphabetically. For GraphQL identifiers ([A-Za-z0-9_]), the sort order matches JavaScript’s localeCompare(), including case handling.

type User {
name: String
age: Int
id: ID
}
code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Source action diff:

1 1 │ type User {
2 │ - ··name:·String
3 │ - ··age:·Int
4 │ - ··id:·ID
2 │ + ··age:·Int
3 │ + ··id:·ID
4 │ + ··name:·String
5 5 │ }
6 6 │

interface Node {
name: String
id: ID
}
code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Source action diff:

1 1 │ interface Node {
2 │ - ··name:·String
3 │ - ··id:·ID
2 │ + ··id:·ID
3 │ + ··name:·String
4 4 │ }
5 5 │

input CreateUserInput {
name: String
age: Int
}
code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Source action diff:

1 1 │ input CreateUserInput {
2 │ - ··name:·String
3 │ - ··age:·Int
2 │ + ··age:·Int
3 │ + ··name:·String
4 4 │ }
5 5 │