Lint your GraphQL with ESLint
GraphQL ESLint integrates GraphQL into ESLint: it parses .graphql files and GraphQL embedded in your code, validates schemas and operations, and enforces the conventions your team agrees on. Part of the Hive ecosystem by The Guild.
- Schema and operations
- Works in your editor
- 60+ rules, custom rules welcome
ESLint, extended to GraphQL
- Lints both sidesRules for the schema you publish and for the operations your clients write, with shared recommended configs for each.
- Code files tooFinds GraphQL in gql tags and /* GraphQL */ comments in JavaScript, TypeScript, Vue and Svelte files and reports at the right location.
- Schema-awareLoads your schema through GraphQL Config, so rules can check that fields exist, types are reachable and deprecated fields are not used.
- Your own rulesThe parser turns the GraphQL AST into ESTree, so custom rules use the ESLint API you already know.
One config object
Register the parser and plugin for .graphql files, pick a shared config or individual rules, and ESLint does the rest — on the command line and in your editor.
Get startedimport graphqlPlugin from '@graphql-eslint/eslint-plugin';
export default [
{
files: ['**/*.graphql'],
languageOptions: {
parser: graphqlPlugin.parser,
},
plugins: {
'@graphql-eslint': graphqlPlugin,
},
rules: {
...graphqlPlugin.configs['flat/schema-recommended'].rules,
'@graphql-eslint/require-description': ['error', { types: true }],
},
},
];Learn more
Rules
Every rule with its category, the configs that enable it, and examples of correct and incorrect code.
Browse the rules →Shared configs
Recommended, all and Relay configs for schemas and operations.
Configs →Custom rules
How the parser maps GraphQL to ESTree, and how to write and test rules of your own.
Write a rule →
Discover the complete ecosystem of tools and libraries
Complete GraphQL Federation Stack
Our libraries to support all your GraphQL needs
Explore the Ecosystem