https://github.com/magicmark/graphql-schema-linter-extras
Additional rules for graphql-schema-linter, including a directive to disable rules for specific nodes of a GraphQL schema.
https://github.com/magicmark/graphql-schema-linter-extras
Last synced: 3 months ago
JSON representation
Additional rules for graphql-schema-linter, including a directive to disable rules for specific nodes of a GraphQL schema.
- Host: GitHub
- URL: https://github.com/magicmark/graphql-schema-linter-extras
- Owner: magicmark
- License: other
- Created: 2019-12-21T01:10:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-15T15:04:00.000Z (almost 7 years ago)
- Last Synced: 2026-01-15T04:29:00.369Z (3 months ago)
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# GraphQL Schema Linter Extras
Additional rules for [graphql-schema-linter](https://github.com/cjoudrey/graphql-schema-linter),
including a directive to disable rules for specific nodes of a GraphQL schema.
## Installation and Usage
Install with `npm i graphql-schema-linter-extras -D`.
Enable the additional rules (see below) in your
[graphql-schema-linter-config](https://github.com/cjoudrey/graphql-schema-linter#configuration-file).
Use `graphql-schema-linter --custom-rule-paths node_modules/graphql-schema-linter-extras/lib/*.js .gql` to lint a schema with the additional rules.
To use the `@lint`-directive (see below),
add the contents of `lint-directive.gql` to your schema.
Make sure `lint-directive` is the first rule in your
[graphql-schema-linter-config](https://github.com/cjoudrey/graphql-schema-linter#configuration-file).
## Rules
### `lint-directive`
Enables the `@lint`-Directive.
```graphql
# For this type, missing field descriptions are allowed
type MyType @lint(disable: ["fields-have-descriptions"]) {
foo: String
# This is not an ID, suppress the typed-ids rule
notAnId: String @lint(disable: ["typed-ids"])
}
```
### `list-items-not-null`
Throws a validation error if a list field's items are nullable.
For example, `[String]` would allow `["foo", null, "baz"]`, which is rarely desired.
### `not-all-fields-null`
Throws a validation error if all fields of a type are nullable, which is rarely desired.
### `typed-ids`
Throws a validation error if a field with an `id` suffix (case-insensitive) is not of type `ID`.