# require-selections

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

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.

## 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]
```

The rule can be disabled for a node and everything nested in it with an `# apigenie-lint-disable require-selections` comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to operations and fragments.

## 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 } }
```

## Compatibility

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.
