# variables-sorted

Source: https://apigenie.pl/docs/linter/graphql/rules/variables-sorted

A rule of the GraphQL linter, which reads GraphQL schemas and operations. Since 0.9.0. In the rulesets: All at error.

This rule checks that the variable definitions of each operation 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 variables-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**.

```graphql
query Users($first: Int, $kind: Kind) { users(first: $first, kind: $kind) { id } }
```

**Bad**. The linter reports `Variable 'first' should come before 'kind'`.

```graphql
query Users($kind: Kind, $first: Int) { users(first: $first, kind: $kind) { id } }
```
