feat(graphql): emit graphql descriptions as tsdoc comments#4054
Open
joelluijmes wants to merge 1 commit into
Open
feat(graphql): emit graphql descriptions as tsdoc comments#4054joelluijmes wants to merge 1 commit into
joelluijmes wants to merge 1 commit into
Conversation
Add an opt-in "emitDescriptions" option to the definitions generator that carries GraphQL schema descriptions into the generated TypeScript as TSDoc/JSDoc comments on types, fields, resolver methods, scalars, enums, enum members and unions. Defaults to false to keep existing generated output unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an opt-in
emitDescriptionsoption toDefinitionsGeneratorOptions. When enabled, GraphQL schema descriptions ("""...""") are emitted as TSDoc/JSDoc comments (/** ... */) on the generated TypeScript definitions.Descriptions are carried through for:
Query/Mutation/Subscription)Why
Today the schema-first definitions generator (
GraphQLDefinitionsFactory→GraphQLAstExplorer) reads the AST but silently discards every node'sdescription. This means the documentation authors write in their SDL never reaches the generated.tsfile, so it's lost to editor tooltips and IntelliSense. This option surfaces that documentation in the generated types.Usage
Given:
produces:
Backward compatibility
The option defaults to
false, so existing generated output is unchanged unless a user opts in.Tests
Added specs in
graphql-ast.explorer.spec.tscovering both the default (descriptions dropped) and enabled (descriptions emitted on types, fields, enums, and enum members) behavior. The full@nestjs/graphqlsuite passes (224 tests).Note
Per CONTRIBUTING this is a small, additive, opt-in feature so it's submitted directly as a PR. Happy to open a
[discussion]issue first if maintainers prefer. Docs for the option can follow in thenestjs/docsrepo if this is accepted.