feat: introduce graphql linting#2856
Conversation
🦋 Changeset detectedLatest commit: e4237dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Performance Benchmark (Lower is Faster)
|
| "operation-summary": "error", | ||
| }, | ||
| "graphql": { | ||
| "no-empty-servers": "error", |
There was a problem hiding this comment.
Those are unused rules propagated from the root rules config section.
7f3750d to
7bd109c
Compare
8723a0d to
73e2aff
Compare
73e2aff to
6bdd8fe
Compare
2b29c2e to
c580a1b
Compare
|
|
||
| // GraphQL SDL is not a JSON/YAML tree, so it runs through a separate engine. | ||
| if (isGraphqlRef(document.source.absoluteRef)) { | ||
| return lintGraphqlDocument({ document, config }); |
There was a problem hiding this comment.
I think, that we can add dynamic imports for the GraphQL in the lint command, because now we have esbuild and chunks, so the dynamic import should go to the separate chunk. It should decrease the influence of the GraphQL on the performance.
b69ae8e to
9c8e4ce
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9c8e4ce. Configure here.
64dd060 to
c94d2b8
Compare
Co-authored-by: Jacek Łękawa <164185257+JLekawa@users.noreply.github.com>
964cf73 to
e4237dc
Compare

What/Why/How?
Added experimental graphql linting.
Reference
Testing
Tests passed here: https://github.com/Redocly/redocly/pull/24589
Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Touches core
lintDocumentand document resolution paths but gates behavior on file extension; new dependency and a parallel rule engine increase surface area while marked experimental.Overview
Adds experimental lint support for GraphQL SDL (
.graphql/.gql) alongside OpenAPI-family formats.redocly lintdetects GraphQL by file extension, keeps SDL as raw text instead of YAML parsing, and runs a dedicated pipeline built on thegraphqlpackage (parse → AST visitors).Built-in GraphQL rules include
struct(syntax +validateSchema),no-unused-types, andtype-description, wired throughgraphqlRulesin presets (recommended,all, etc.) and the default plugin. Configurablerule/*assertions work against GraphQL AST kinds (ObjectTypeDefinition,FieldDefinition, …) via a new GraphQL assertions visitor, withredocly.yamlsubject enums extended accordingly.Config/plugins gain a
graphqlrules bucket; common ref-resolution rules likeno-unresolved-refsare omitted from the GraphQL ruleset. Bundling explicitly skips GraphQL. Docs add a GraphQL lint guide and updatelint/ configurable-rules pages; enum validation errors for huge subject lists now link to documentation instead of dumping all values.Reviewed by Cursor Bugbot for commit e4237dc. Bugbot is set up for automated code reviews on this repo. Configure here.