useSortedSelectionSet (GraphQL)
Language GraphQL
Summary
Section titled “Summary”- Rule available since:
v2.5.0 - 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 selections inside GraphQL operations and fragments.
The action places fields first, named fragment spreads such as ...UserFields next, and
inline fragments such as ... on User last. Within each group, names use natural order,
which compares numbers by value.
An aliased field is sorted by its alias. For example, firstName: name is sorted under
firstName, which is the name returned in the response.
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.