# match-document-filename

Source: https://apigenie.pl/docs/linter/graphql/rules/match-document-filename

This rule checks that the file name of a document with one operation or fragment is the name of the definition.

## Rule Details

Files named after their operation are easy to find. Documents with several definitions are not checked (see `lone-executable-definition`).

## Configuration

The configuration block is an object with the properties:

- `style`: the case of the file name, `camelCase`, `camelCaseStrict`, `PascalCase`, `PascalCaseStrict`, `snake_case`,
  `CONST_CASE` (or `UPPER_CASE`), `kebab-case` or `Header-Case`; the strict forms reject two
  capitals in a row (`userID`); the name as written by default
- `fileExtension`: the extension the file must have, e.g. `.gql`; any by default

```yaml
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        match-document-filename: [error, { style: kebab-case, fileExtension: .graphql }]
```

The rule can be disabled for a node and everything nested in it with an `# apigenie-lint-disable match-document-filename` 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
# GetUser.graphql
query GetUser { me { id } }
```

**Bad**. The linter reports `The file name 'user.graphql' should match the query 'GetUser', e.g. 'GetUser.graphql'`.

```graphql
# user.graphql
query GetUser { me { id } }
```
