Skip to content

useSortedSelectionSet

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

Sort GraphQL selection sets.

This rule orders fields first, fragment spreads next, and inline fragments last. Within each category, identifiers are sorted alphabetically.

For fields, aliases are used as the sort key when present. This keeps selections deterministic and easier to scan in reviews.

query {
id
...bFragment
firstName: name
... on Contact {
phoneNumber
email
}
age
... on Address {
street
city
}
...aFragment
}
code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source action diff:

1 1 query {
2 - ··id
3 - ··...bFragment
4 - ··firstName:·name
5 - ··...·on·Contact·{
6 - ····phoneNumber
7 - ····email
2+ ··age
3+ ··firstName:·name
4+ ··id
5+ ··...aFragment
6+ ··...bFragment
7+ ··...·on·Address·{
8+ ····street
9+ ····city
8 10 }
9 - ··age
10 - ··...·on·Address·{
11 - ····street
12 - ····city
11+ ··...·on·Contact·{
12+ ····phoneNumber
13+ ····email
13 14 }
14 - ··...aFragment
15 15 }
16 16

code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source action diff:

4 4 firstName: name
5 5 … on Contact {
6 - ····phoneNumber
7 - ····email
6+ ····email
7+ ····phoneNumber
8 8 }
9 9 age

code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source action diff:

9 9 age
10 10 … on Address {
11 - ····street
12 - ····city
11+ ····city
12+ ····street
13 13 }
14 14 …aFragment

query {
age
firstName: name
id
...aFragment
...bFragment
... on Address {
city
street
}
... on Contact {
email
phoneNumber
}
}