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 by name.

The action sorts fields inside type, interface, and input definitions. Underscores come first, followed by digits and then letters. Letter case is ignored first; when names otherwise match, lowercase letters come before uppercase letters.

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 │