fix(codegen): upstream CLI fixes - no-arg query, field defaults, NodeHttpAdapter as top-level option#737
Merged
pyramation merged 5 commits intomainfrom Feb 24, 2026
Conversation
…ults, localhost adapter
1. Fix query call signature for no-arg queries (e.g. currentUser)
- buildOrmCustomCall now skips empty args object and passes {select} as single param
- Fixes: .currentUser({}, {select}) -> .currentUser({select})
2. Mark fields with defaults as not-required in create operations
- Uses TypeRegistry to look up CREATE input type's defaultValue from introspection
- Fields with defaults or nullable types are marked required: false
- Passed via new typeRegistry option on TableCommandOptions
3. Add localhost fetch adapter for *.localhost subdomain routing
- New template: localhost-fetch.ts patches globalThis.fetch using node:http.request
- Enables local dev with subdomain routing (e.g. auth.localhost:3000)
- Configurable via cli.localhostAdapter option in CliConfig
- Auto-imported in executor when enabled
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:
|
added 3 commits
February 24, 2026 10:22
Replaces the localhost-fetch.ts global monkey-patch with a clean NodeHttpAdapter class that implements GraphQLAdapter using node:http/https. - No global patching of globalThis.fetch - NodeHttpAdapter handles *.localhost DNS + Host header internally - Executor passes adapter to createClient instead of side-effect import - Follows same pattern as FetchAdapter in orm-client.ts - Follows same http.request pattern as fetch-schema.ts
…tion - Move nodeHttpAdapter from CliConfig to GraphQLSDKConfigTarget - Auto-enable nodeHttpAdapter when CLI generation is enabled (unless explicitly false) - Generate node-fetch.ts in ORM output when nodeHttpAdapter is enabled - Export NodeHttpAdapter from ORM index.ts for standalone Node.js usage - Pass nodeHttpAdapter to multi-target CLI generator - Update template comment to reflect general Node.js usage (not CLI-specific) This allows any Node.js application (ORM, CLI, or custom) to use NodeHttpAdapter for localhost subdomain routing without needing CLI generation enabled.
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.
fix(codegen): upstream CLI fixes — no-arg queries, field defaults, NodeHttpAdapter as top-level option
Summary
Three upstream codegen fixes that eliminate workarounds previously needed in the bash CLI e2e test script. These are bugs discovered during CLI end-to-end testing in constructive-hub.
1. No-arg query call signature (custom-command-generator.ts)
Queries with zero arguments (e.g.
currentUser) generated.currentUser({}, { select })— an extraneous empty args object. The ORM expects.currentUser({ select }). Fixed by adding ahasArgsflag tobuildOrmCustomCallthat omits the empty args when the operation has no arguments.2. Fields with defaults marked not-required (table-command-generator.ts)
All create-mutation fields were marked
required: trueregardless of whether they have database defaults or are trigger-populated. NewgetFieldsWithDefaults()looks up theCreateXInputtype in theTypeRegistry(from introspection) and checks each inner field'sdefaultValueand nullability. Fields with defaults or nullable types are nowrequired: false.3. NodeHttpAdapter — elevated to top-level generation option
NodeHttpAdapter(intemplates/node-fetch.ts) implements theGraphQLAdapterinterface usingnode:http/node:httpsdirectly — no global patching.What changed since last revision:
nodeHttpAdapterwas moved fromCliConfigtoGraphQLSDKConfigTargetso it's available to any generator (ORM, CLI, or custom Node.js apps), not just CLI.New behavior:
nodeHttpAdapter: trueon the top-level config generatesnode-fetch.tsin the ORM output directory and re-exportsNodeHttpAdapterfrom the ORM indexcli: true),nodeHttpAdapteris auto-enabled unless explicitly set tofalseUpdates since last revision
nodeHttpAdapterfromCliConfigtoGraphQLSDKConfigTarget— now usable by ORM and any Node.js application, not just CLIcli: true,nodeHttpAdapteris automatically enabled unlessnodeHttpAdapter: falseis explicitly setnode-fetch.tsis generated intoorm/andNodeHttpAdapteris re-exported from the ORMindex.tsgenerateMultipassesnodeHttpAdapterthrough to the unified CLI generator (defaults to enabled)Review & Testing Checklist for Human
cli: trueis set without mentioningnodeHttpAdapter, the adapter is now auto-generated. Verify this doesn't break any existing downstream configs that don't expect anode-fetch.tsin their output. The snapshot tests pass, but they may not cover configs withcli: truethat were generated before this change.orm: true, nodeHttpAdapter: true(no CLI) and verifyimport { NodeHttpAdapter } from './orm'works correctly. The re-export depends on the file being generated — if the generation logic has a bug, the import will fail.generateMulti,nodeHttpAdapterdefaults totrueunless the first target explicitly setsnodeHttpAdapter: false. This could be surprising if users expect opt-in behavior. Test a multi-target config to verify the default is acceptable.@constructive-io/graphql-typesdependency:node-fetch.tstemplate importsGraphQLAdapter,GraphQLError,QueryResultfrom@constructive-io/graphql-types. Confirm generated ORM projects (not just CLI) always have this dependency available.Notes
pnpm buildsucceeds across all packages.packages/csv-to-pg) is a minio container port conflict — unrelated to these changes.typeRegistryis not provided, behavior is unchanged (all fields remainrequired: truefor create).generateNodeFetchFileutility is imported dynamically from./codegen/cli/utils-generatoringenerate.tswhen generating ORM output. This is a minor code organization coupling but not a functional issue.Link to Devin run: https://app.devin.ai/sessions/d41228699b3a46de9e73cc13dda02882
Requested by: @pyramation