# match-document-filename

Source: https://api-genie.dev/docs/linter/graphql/rules/match-document-filename

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 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`).

The rule applies to operations and fragments. An `# apigenie-lint-disable match-document-filename`
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 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 }]
```

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