feat: consolidate codegen test helper + runtime deep path#1023
Merged
pyramation merged 9 commits intomainfrom Apr 27, 2026
Merged
feat: consolidate codegen test helper + runtime deep path#1023pyramation merged 9 commits intomainfrom
pyramation merged 9 commits intomainfrom
Conversation
#1: Move runCodegenAndLoad into @constructive-io/graphql-test - New codegen-helper.ts in graphql-test/src/ with full codegen pipeline - Supports both positional (GraphQLQueryFn) and object-style (GraphQLQueryFnObj) - Re-exports getDbConnections and types from pgsql-test for two-phase patterns - orm-test now imports from @constructive-io/graphql-test instead of local copy - Deleted local orm-test codegen-helper.ts #2: Add runtime sub-export to @constructive-io/graphql-query - New graphql-query/src/runtime/index.ts re-exports: - parseType, print from @0no-co/graphql.web - All gql-ast exports - GraphQLAdapter, GraphQLError, QueryResult types from graphql-types - Updated codegen templates (query-builder.ts, orm-client.ts) to import from @constructive-io/graphql-query/runtime instead of 3 separate packages - Updated codegen test snapshots and assertions to match new import paths
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:
|
The runtime sub-export re-exports parseType, print, and type-only symbols. Using 'import * as t from runtime' would pollute the t namespace with unrelated symbols. Keep 'import * as t from gql-ast' as-is in templates.
…tion The cli-e2e tests generate ORM code in /tmp and require the runtime sub-path. Without an explicit exports map, Node cannot resolve @constructive-io/graphql-query/runtime. This adds exports for both the root and ./runtime sub-paths (CJS, ESM, and types).
…lution The cli-e2e tests spawn child processes in /tmp that need to resolve @constructive-io/graphql-query/runtime. Adding the package to resolveNodePaths() so its node_modules path is included in NODE_PATH.
…b-path resolution The cli-e2e tests spawn child processes that need to resolve @constructive-io/graphql-query/runtime via NODE_PATH. Adding the package as a devDependency so pnpm creates a symlink in server-test/node_modules, making the exports field accessible.
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
Add exports field to graphql-codegen package.json with ./orm sub-path so generateOrm is a stable contract instead of a filesystem crawl. Update codegen-helper.ts to use clean import from @constructive-io/graphql-codegen/orm.
…ructive standard The Constructive dist-folder publishing pattern (publishConfig.directory: dist) makes deep nested imports work naturally — no exports map needed. - Remove exports + typesVersions from graphql-codegen/package.json - Remove exports from graphql-query/package.json - Revert cli-e2e.test.ts to deep path imports (core/codegen/cli, core/codegen/orm) - Update codegen-helper.ts to deep path import (core/codegen/orm)
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
5 tasks
Zetazzz
pushed a commit
to Zetazzz/Constructive
that referenced
this pull request
May 6, 2026
…ate ORM code PR constructive-io#1023 changed codegen templates to import from @constructive-io/graphql-query/runtime instead of directly from @constructive-io/graphql-types and @0no-co/graphql.web. The SDK packages (constructive-cli, constructive-sdk, constructive-react, migrate-client) were missing @constructive-io/graphql-query as a dependency, causing TS2307 'Cannot find module' errors when building regenerated code. Fix: - Add @constructive-io/graphql-query: workspace:^ to all 4 SDK package.json - Regenerate all SDK ORM code with updated codegen templates
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.
Summary
Three packaging consolidations that emerged from the PR #934 refactoring work:
#1 — Move
runCodegenAndLoadinto@constructive-io/graphql-testThe codegen test helper (introspect → infer tables → generate ORM → compile TS → load
createClient) was duplicated betweenorm-testandconstructive-db. This PR:graphql/test/src/codegen-helper.tswith a version that supports both positional (GraphQLQueryFn) and object-style (GraphQLQueryFnObj) query signaturesgetDbConnectionsand related types frompgsql-testfor two-phase test patterns@constructive-io/graphql-testorm-test/__tests__/helpers/codegen-helper.ts#2 — Add
@constructive-io/graphql-query/runtimedeep path moduleGenerated ORM code currently imports from 3 separate runtime packages (
@0no-co/graphql.web,gql-ast,@constructive-io/graphql-types). This PR consolidates two of the three:graphql/query/src/runtime/index.tsthat re-exports@0no-co/graphql.web(parseType,print) and@constructive-io/graphql-types(GraphQLAdapter,GraphQLError,QueryResult)@0no-co/graphql.weband@constructive-io/graphql-typesas explicit dependencies ofgraphql-query(they were previously only transitive)query-builder.tstemplate:parseType/printnow import from@constructive-io/graphql-query/runtimeorm-client.tstemplate:GraphQLAdapter/GraphQLError/QueryResulttypes now import from@constructive-io/graphql-query/runtimegql-astis intentionally not re-exported —import * as t from 'gql-ast'stays as-is to avoid polluting thetnamespaceclient-generator.test.tspublishConfig.directory: "dist") — noexportsmap needed, per Constructive standard#3 — Replace
require.resolvehack with deep path import forgenerateOrmThe codegen-helper previously used a fragile
require.resolve+path.joinhack to reach into@constructive-io/graphql-codegeninternals forgenerateOrm. This PR replaces it with a clean deep path import:codegen-helper.tsnow usesimport { generateOrm } from '@constructive-io/graphql-codegen/core/codegen/orm'— a standard deep path import that works via dist-folder publishingrequire.resolve+require()+as anypattern that had no type safetycli-e2e.test.tsalready used deep path imports (@constructive-io/graphql-codegen/core/codegen/cliandcore/codegen/orm) — no change needed thereUpdates since last revision
exportsmap anti-pattern — per the Constructive publishing standard, theexportsfield should never be used. Dist-folder publishing (publishConfig.directory: "dist") makes deep nested imports work naturally. RemovedexportsandtypesVersionsfromgraphql-codegen/package.jsonandexportsfromgraphql-query/package.json. Revertedcli-e2e.test.tsandcodegen-helper.tsto use deep path imports (e.g.@constructive-io/graphql-codegen/core/codegen/orm) instead of sub-path exports.Review & Testing Checklist for Human
query-builder.tsandorm-client.tsnow import from@constructive-io/graphql-query/runtimeinstead of@0no-co/graphql.weband@constructive-io/graphql-types. All downstream repos will produce new import paths on next codegen run. Verify they already have@constructive-io/graphql-queryas a dependency and that the/runtimedeep path resolves correctly with dist-folder publishing.codegen-helper.tsimports from@constructive-io/graphql-codegen/core/codegen/ormandcli-e2e.test.tsimports fromcore/codegen/cliandcore/codegen/orm. These work via dist-folder publishing but will break if the internalcore/codegen/directory structure changes. Confirm this coupling is acceptable.codegen-helper.ts:queryFn.length <= 1to distinguish object-style from positional. Verify this heuristic is correct for all graphile-test query wrappers.orm-testandserver-testsuites against a real DB to confirm the deep path imports resolve correctly end-to-end (CI covers this, but worth watching).Notes
gql-astremains a direct import inquery-builder.ts(import * as t from 'gql-ast') — this is intentional to keep thetnamespace clean. The runtime module consolidates the other two runtime deps only.pnpm-lock.yamldiff is mostly formatting noise from a pnpm version change — the actual dependency changes are just the added workspace deps.exportsmap is used anywhere in this PR — all sub-module access uses deep path imports per Constructive's dist-folder publishing standard.Link to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation