# lone-executable-definition

Source: https://apigenie.pl/docs/linter/graphql/rules/lone-executable-definition

This rule checks that a document holds a single operation or fragment.

## Rule Details

One definition per file keeps files small, and lets tools map files to operations.

## Configuration

The configuration block is an object with the `ignore` property: the kinds of definitions
(`query`, `mutation`, `subscription`, `fragment`) that may be added to a document.

```yaml
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        lone-executable-definition: [error, { ignore: [fragment] }]
```

The rule can be disabled for a node and everything nested in it with an `# apigenie-lint-disable lone-executable-definition` 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 } }
```

**Bad**. The linter reports `Operation 'Users' should be in a document of its own; a document should hold one operation or fragment`.

```graphql
query Me { me { id } }
query Users { users { id } }
```
