Registry / testing / eslint-plugin-graphql-schema

eslint-plugin-graphql-schema

JSON →
library2.0.3jsnpmunverified

ESLint plugin for validating GraphQL schema definitions with rules for descriptions, naming conventions, ordering, and required patterns. Version 2.0.3 is the latest stable release, updated as needed via GitHub. Key differentiators: focused solely on schema validation (not operations), supports .graphql and .gql file extensions, and provides a custom parser for direct linting. Includes 15 rules covering arguments, enums, input objects, and object types.

npm install eslint-plugin-graphql-schema
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-GRAP
E
eslint-plugin-graphql-schema
testingjavascriptv2.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

eslint-plugin-graphql-schema
✓ npm install eslint-plugin-graphql-schema --save-dev
✗ npm install eslint-plugin graphql-schema
Install as a dev dependency; the plugin is referenced by name 'graphql-schema' in .eslintrc.
rules
✓ { "plugins": ["graphql-schema"], "rules": { "graphql-schema/arguments-have-descriptions": "warn" } }
✗ { "rules": { "arguments-have-descriptions": "warn" } }
All rules must be prefixed with 'graphql-schema/' when configured in rules.
parser
✓ "parser": "eslint-plugin-graphql-schema/parser"
✗ "parser": "graphql-schema"
The custom parser is required for linting .graphql files directly; it's exported from the plugin package.

Configures ESLint with the graphql-schema plugin and custom parser for .graphql files, with example schema that complies with rules.

// .eslintrc.json { "overrides": [ { "files": ["*.graphql"], "parser": "eslint-plugin-graphql-schema/parser", "plugins": ["graphql-schema"], "rules": { "graphql-schema/arguments-have-descriptions": "error", "graphql-schema/defined-types-are-used": "error", "graphql-schema/enum-values-have-descriptions": "error", "graphql-schema/type-fields-have-descriptions": "error" } } ] } // schema.graphql type Query { "Get a user by ID" user(id: ID!): User } "Represents a user" type User { "Unique identifier" id: ID! "User's name" name: String! } enum Role { "Administrator role" ADMIN "Regular user" USER }
Debug
Known issues
gotchaRequires ESLint 6+ and Node >=12
fix
Ensure ESLint version is 6 or higher and Node version is 12 or higher.
affects: >=2.0.0
gotchaCustom parser must be explicitly set for .graphql files
fix
Add 'parser': 'eslint-plugin-graphql-schema/parser' in ESLint config overrides for .graphql files.
affects: >=1.0.0
gotchaRules must be prefixed with graphql-schema/
fix
Reference rules as 'graphql-schema/rule-name' in ESLint config.
affects: >=1.0.0
gotchaPlugin only validates schemas, not operations (queries/mutations)
fix
Use eslint-plugin-graphql for operation validation.
affects: >=1.0.0
deprecatedRule 'types-have-descriptions' may be deprecated in favor of more specific rules
fix
Check documentation; use 'type-fields-have-descriptions' or 'input-object-values-have-descriptions' as appropriate.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Failed to load parser 'eslint-plugin-graphql-schema/parser' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-graphql-schema/parser'
The plugin is not installed or the parser path is incorrect.
fix
Run 'npm install eslint-plugin-graphql-schema --save-dev' and ensure the parser is written exactly as 'eslint-plugin-graphql-schema/parser'.
Error: Configuration for rule "graphql-schema/arguments-have-descriptions" is invalid: Value "off" is not accepted. Expected boolean or object.
Rule severity must be 'off', 'warn', 'error' (strings) or 0/1/2.
fix
Use strings: "graphql-schema/arguments-have-descriptions": "off".
TypeError: Cannot read properties of undefined (reading 'type')
The parser is not applied to .graphql files, or the file doesn't contain a valid GraphQL schema.
fix
Ensure the 'parser' is set correctly and the file has a schema definition (e.g., type Query { ... }).
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; required for plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-graphql-schema — npm install eslint-plugin-graphql-schema · libregistry