# require-selections

Source: https://apigenie.pl/docs/linter/graphql/rules/require-selections

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

This rule checks that selections of objects with an identifier select it.

## Rule details

Clients such as Apollo Client and Relay cache and update objects by their identifier; an object fetched without it cannot be normalized. The identifier may be selected directly, in inline fragments or in the fragments of the document.

The rule checks operations against the schema files named by the `schema` property of the
configuration, or against the type system of their own document. It reports nothing without a
schema.

The rule applies to operations and fragments. An `# apigenie-lint-disable require-selections`
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.

## Configuration

The configuration block can be a string, the name of the identifier field, or an object
with the `fieldName` property. The name is `id` by default.

```yaml
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        require-selections: [error, uuid]
```

## Examples

**Good**.

```graphql
query Me { me { id name } }
```

**Bad**. The linter reports `Field 'me' should select 'id', which identifies its type 'User'`.

```graphql
query Me { me { name } }
```
