Available Configs
Name | Description |
---|---|
schema-recommended (opens in a new tab) | enables recommended rules for schema (SDL) development |
schema-all (opens in a new tab) | enables all rules for schema (SDL) development, except for those that require parserOptions.operations option |
operations-recommended (opens in a new tab) | enables recommended rules for consuming GraphQL (operations) development |
operations-all (opens in a new tab) | enables all rules for consuming GraphQL (operations) development |
relay (opens in a new tab) | enables rules from Relay specification for schema (SDL) development |
⚠️
If you are in a project that develops the GraphQL schema, you'll need schema
rules.
If you are in a project that develops GraphQL operations (query
/mutation
/subscription
), you'll
need operations
rules.
If you are in a monorepo project, you probably need both sets of rules, see example of configuration (opens in a new tab).
Config Usage
For example, to enable the schema-recommended
config, enable it in your .eslintrc
file with the
extends
option:
.eslintrc.json
{
"overrides": [
{
"files": ["*.js"],
"processor": "@graphql-eslint/graphql"
},
{
"files": ["*.graphql"],
- "parser": "@graphql-eslint/eslint-plugin",
- "plugins": ["@graphql-eslint"],
+ "extends": "plugin:@graphql-eslint/schema-recommended"
}
]
}
💡
All configs under the hood set parser
as @graphql-eslint/eslint-plugin
and add
@graphql-eslint
to plugins
array, so you don't need to specify them.