<commit_before># graphql-schema-linter [![Travis CI](https://travis-ci.org/cjoudrey/graphql-schema-linter.svg?branch=master)](https://travis-ci.org/cjoudrey/graphql-schema-linter)

This package provides a command line tool to validate GraphQL schema definitions against a set of rules.

![](https://raw.githubusercontent.com/cjoudrey/graphql-schema-linter/master/screenshot.png)

If you're looking to lint your GraphQL queries, check out this ESLint plugin: [apollographql/eslint-plugin-graphql](https://github.com/apollographql/eslint-plugin-graphql).

## Install

Yarn:

```
yarn global add graphql-schema-linter
```

npm:

```
npm install -g graphql-schema-linter
```

## Usage

```
Usage: graphql-schema-linter [options] [schema.graphql]


Options:

  -o, --only <rules>

    only the rules specified will be used to validate the schema

    example: --only FieldsHaveDescriptions,TypesHaveDescriptions

  -e, --except <rules>

    all rules except the ones specified will be used to validate the schema

    example: --except FieldsHaveDescriptions,TypesHaveDescriptions

  -f, --format <format>

    choose the output format of the report

    possible values: json, text

  -s, --stdin

    schema definition will be read from STDIN instead of specified file

  --version

    output the version number

  -h, --help

    output usage information
```

## Built-in rules

### `DeprecationsHaveAReason`

This rule will validate that all deprecations have a reason.

### `EnumValuesSortedAlphabetically`

This rule will validate that all enum values are sorted alphabetically.

### `FieldsHaveDescriptions`

This rule will validate that all fields have a description.

### `TypesAreCapitalized`

This rule will validate that interface types and object types have capitalized names.

### `TypesHaveDescriptions`

This will will validate that interface types and object types have descriptions.

## Output formatters

The format of the output can be controlled via the `--format` option.

The following formatters are currently available: `text`, `json`.

### `TextFormatter` (default)

Sample output:

```
5:1 The object type `QueryRoot` is missing a description.
6:3 The field `QueryRoot.a` is missing a description.

2 errors detected
```

Each error is prefixed with the line number and column the error occurred on.<commit_msg>Update README with new use of --only and --except<commit_after># graphql-schema-linter [![Travis CI](https://travis-ci.org/cjoudrey/graphql-schema-linter.svg?branch=master)](https://travis-ci.org/cjoudrey/graphql-schema-linter)

This package provides a command line tool to validate GraphQL schema definitions against a set of rules.

![](https://raw.githubusercontent.com/cjoudrey/graphql-schema-linter/master/screenshot.png)

If you're looking to lint your GraphQL queries, check out this ESLint plugin: [apollographql/eslint-plugin-graphql](https://github.com/apollographql/eslint-plugin-graphql).

## Install

Yarn:

```
yarn global add graphql-schema-linter
```

npm:

```
npm install -g graphql-schema-linter
```

## Usage

```
Usage: graphql-schema-linter [options] [schema.graphql]


Options:

  -o, --only <rules>

    only the rules specified will be used to validate the schema

    example: --only fields-have-descriptions,types-have-descriptions

  -e, --except <rules>

    all rules except the ones specified will be used to validate the schema

    example: --except fields-have-descriptions,types-have-descriptions

  -f, --format <format>

    choose the output format of the report

    possible values: json, text

  -s, --stdin

    schema definition will be read from STDIN instead of specified file

  --version

    output the version number

  -h, --help

    output usage information
```

## Built-in rules

### `deprecations-have-a-reason`

This rule will validate that all deprecations have a reason.

### `enum-values-sorted-alphabetically`

This rule will validate that all enum values are sorted alphabetically.

### `fields-have-descriptions`

This rule will validate that all fields have a description.

### `types-are-capitalized`

This rule will validate that interface types and object types have capitalized names.

### `types-have-descriptions`

This will will validate that interface types and object types have descriptions.

## Output formatters

The format of the output can be controlled via the `--format` option.

The following formatters are currently available: `text`, `json`.

### `TextFormatter` (default)

Sample output:

```
5:1 The object type `QueryRoot` is missing a description.
6:3 The field `QueryRoot.a` is missing a description.

2 errors detected
```

Each error is prefixed with the line number and column the error occurred on.
{'fraction_non_alphanumeric': 0.09822184589331075, 'fraction_numerical': 0.0021168501270110076, 'mean_word_length': 4.119176598049838, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '156189', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1350, 'n_words': 505}