feat(codegen): render PostgreSQL comments as JSDoc + add @constructive-io/react package#751
Merged
pyramation merged 8 commits intomainfrom Feb 28, 2026
Merged
Conversation
…cript - Add description fields to CleanTable and CleanField types - Create stripSmartComments utility to separate PostGraphile smart comments - Populate descriptions from introspection in inferTablesFromIntrospection - Emit JSDoc comments on entity types, fields, enums in input-types-generator - Emit JSDoc comments on types/fields in schema-types-generator (non-ORM mode) - Emit JSDoc comments on operation variables in custom-ops-generator - Handle custom input types and payload types descriptions from TypeRegistry
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
… output Strip generic PostGraphile-generated descriptions that add noise: - 'The exclusive input argument for this mutation...' - 'An arbitrary string value with no semantic meaning...' - 'The output of our...' - 'All input for the...' Uses startsWith matching to handle curly apostrophe variants.
…rsor, edge, pagination descriptions Added additional PostGraphile boilerplate prefixes: - 'The exact same clientMutationId that was provided...' - 'A cursor for use in pagination.' - 'An edge for our...' - 'Information to aid in pagination.' - 'Reads and enables pagination through a set of...' - 'A list of edges which contains the...' - And several more generic PostGraphile descriptions Removes 2,468 additional lines of noise from the generated SDK.
Use table.description (from COMMENT ON TABLE) when available, fall back to generic text otherwise. Applied consistently across: - queries.ts: list/single query hooks, fetch functions, prefetch functions - mutations.ts: create/update/delete mutation hooks - hooks-docs-generator.ts: README, AGENTS.md, MCP tools, skills - orm/docs-generator.ts: MCP tools, skills Regenerated both SDK and React packages with updated output.
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.
feat(codegen): render PostgreSQL comments as JSDoc + add @constructive-io/react package
Summary
Ensures PostgreSQL
COMMENT ONstatements flow through GraphQL introspection and are rendered as JSDoc comments in all generated TypeScript code. Also adds a safety-net utility to strip PostGraphile smart comments (lines starting with@) from descriptions, and filters out generic PostGraphile boilerplate descriptions that add noise rather than value.JSDoc comments are configurable via
codegen.comments(default:true). When set tofalse, all JSDoc comment generation is suppressed.Table-level descriptions are threaded everywhere. When a table has a
COMMENT ON TABLEdescription, it replaces the generic text (e.g., "List query hook for X") in hook JSDoc, ORM MCP tools, skills docs, README, and AGENTS.md. When no table description exists, the generic fallback is used. This applies to all generators: queries, mutations, hooks docs, and ORM docs.Codegen changes (
graphql/codegen/):types/config.ts: Addedcomments?: booleanoption tocodegenconfig section (default:true)types/schema.ts: Added optionaldescriptionfield toCleanTableandCleanFieldinterfacescore/codegen/utils.ts: NewstripSmartComments()utility withenabledparameter — removes@-prefixed lines, filters PostGraphile boilerplate, and respects thecommentsconfig flagcore/introspect/infer-tables.ts: Populatesdescriptionon tables and fields from introspection data, gated bycommentsoption viaInferTablesOptionscore/pipeline/index.ts: Readsconfig.codegen?.commentsand passes it through toinferTablesFromIntrospectioncore/codegen/orm/index.ts: ORM orchestrator readscommentsfrom config and passes to all generatorscore/codegen/shared/index.ts: Shared orchestrator passescommentsthrough togenerateSchemaTypesFilecore/codegen/orm/input-types-generator.ts: Emits JSDoc on entity types, entity fields, enum types, custom input types/fields, and payload types/fields — all gated bycommentsparamcore/codegen/schema-types-generator.ts: Emits JSDoc on enums, input objects, unions, and payload object types — all gated bycommentsparam viaGenerateSchemaTypesOptionscore/codegen/orm/custom-ops-generator.ts: Emits JSDoc on operation variable interfaces and their argument properties — gated bycommentsparamcore/codegen/queries.ts: Usestable.description(with generic fallback) for list/single query hooks, fetch functions, and prefetch functionscore/codegen/mutations.ts: Usestable.description(with generic fallback) for create/update/delete mutation hooks and file headerscore/codegen/hooks-docs-generator.ts: Usestable.description(with generic fallback) in README tables, AGENTS.md hook descriptions, MCP tool descriptions, and skills filescore/codegen/orm/docs-generator.ts: Usestable.description(with generic fallback) in MCP tool descriptions and skills filescore/generate.ts: Added explicitGraphQLSDKConfigTargettype annotation tobaseConfigingenerateMultiSDK regeneration (
sdk/constructive-sdk/src/):pnpm generateinsdk/constructive-sdk/to regenerate the SDK using the updated codegenadmin,auth,objects, andpublicschemasstore.md→ "A store represents an isolated object repository within a database." instead of "ORM operations for Store records")New @constructive-io/react package
Added
sdk/constructive-react/— a new package that generates React Query hooks (v5) + ORM client from the same schema files used byconstructive-sdk. This package verifies that JSDoc comments propagate correctly through:Package structure:
package.json— declares@tanstack/react-queryv5,@0no-co/graphql.web, and workspace depsscripts/generate-react.ts— mirrorsconstructive-sdk's generation script withreactQuery: trueandorm: true, now with explicitGraphQLSDKConfigTargettype annotationsrc/{admin,auth,objects,public}/— generated targets withhooks/andorm/subdirectoriessrc/index.ts— barrel exports all targets (usespublic_for thepublicschema to avoid reserved word)Generated output includes:
.mdfiles) for each operationPostGraphile boilerplate filtering
stripSmartComments()suppresses generic PostGraphile-generated descriptions usingstartsWithprefix matching. This handles curly apostrophe variants PostGraphile may produce. Filtered prefixes:"The exclusive input argument for this mutation.""An arbitrary string value with no semantic meaning.""The exact same \clientMutationId` that was provided in the mutation input,"`"The output of our""All input for the""A cursor for use in pagination.""An edge for our""Information to aid in pagination.""Reads and enables pagination through a set of""The count of *all* \"`"A list of \"`"Our root query field""Reads a single""The root query type""The root mutation type"Updates since last revision
GraphQLSDKConfigTargettype annotations tobaseConfigobjects in generation scripts (generate-react.ts,generate-sdk.ts) and internalgenerate.tsto improve type safety and IDE support.Review & Testing Checklist for Human
useStoresQuery,useCreateCommitMutation) and verify that table descriptions appear in JSDoc tooltips when available. Check that generic fallback text appears for tables without descriptions.sdk/constructive-sdk/src/public/orm/skills/store.mdand verify they show meaningful table descriptions (e.g., "A store represents an isolated object repository within a database.") instead of generic text.startsWithmatching on short prefixes like"Reads a single","A list of \","The output of our"could suppress a legitimate custom PostgreSQLCOMMENT` that happens to begin with those phrases. Consider whether exact-match or longer prefixes would be safer."An edge for our \User`. May be used by Relay 1."(filtered) while others use"A `User` edge in the connection."` (NOT filtered). The latter format still appears in generated code (visible in the diff). Verify whether this is acceptable or if additional patterns need filtering.comments: falsepath is untested: The PR only verified thatcomments: true(default) produces the expected output. Thecomments: falsepath has not been tested end-to-end. Recommend testing with a config that setscodegen: { comments: false }to verify all JSDoc is suppressed.Notes
stripSmartComments, boilerplate filtering, JSDoc output verification, table description threading, or thecomments: falsepath.pnpm buildpasses. All 42 CI checks passed on all commits.@constructive-io/reactpackage adds ~1,000 generated files to the repo. This mirrors the pattern used byconstructive-sdk.table.description || generic), so empty string descriptions would also fall back to generic text.appAchievementdescription) — these are not codegen bugs but reflect the source data.Link to Devin run: https://app.devin.ai/sessions/a23198fb88394660869ebbbe14cc8f39
Requested by: @pyramation