useSortedSelectionSet
Summary
Section titled “Summary”- Diagnostic Category:
assist/source/useSortedSelectionSet - Sources:
- Inspired from
@graphql-eslint/alphabetize
- Inspired from
How to enable in your editor
Section titled “How to enable in your editor”{ "editor.codeActionsOnSave": { "source.action.useSortedSelectionSet.biome": "explicit", "source.fixAll.biome": "explicit" }}{ "code_actions_on_format": { "source.action.useSortedSelectionSet.biome": true, "source.fixAll.biome": true }}
Use the source action code
source.action.useSortedSelectionSet.biome How to configure
Section titled “How to configure”{ "assist": { "actions": { "source": { "useSortedSelectionSet": "on" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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 }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.