selections-sorted

Since 0.9.0 · In the rulesets: All at error

This rule checks that the fields of each selection set of operations and fragments are in alphabetical order.

Rule details

Sorted definitions are easier to find and produce smaller diffs. Names are compared ignoring case; the first name out of order of each list is reported.

Turn the rule off when the order of definitions is meaningful, for example the most important fields first.

The rule applies to operations and fragments. An # apigenie-lint-disable selections-sorted comment on a node turns it off for the node and everything nested in it; at the top of the file, separated from the first definition by a blank line, the comment turns it off for the whole file.

Examples

Good.

query Me { me { id name } }

Bad. The linter reports Field 'id' should come before 'name'.

query Me { me { name id } }

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.

commands:
  lint:
    graphql:
      rules:
        selections-sorted: off
Last updated on View as Markdown
Was this helpful?