Skip to content

refactor(codegen): remove default selects entirely (Path A)#694

Open
pyramation wants to merge 10 commits intomainfrom
feat/remove-default-selects
Open

refactor(codegen): remove default selects entirely (Path A)#694
pyramation wants to merge 10 commits intomainfrom
feat/remove-default-selects

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Feb 7, 2026

refactor(codegen): remove default selects entirely, make selection required

Summary

Removes all default select logic from the codegen package (Path A). Previously, every generated hook and ORM model method had two overloads: one requiring an explicit fields/select, and a second that fell back to a const defaultSelect = { id: true } as const when no fields were provided. This "magic" fallback is removed — selection with fields is now required in all hook and ORM method signatures.

What was removed:

  • getDefaultSelectFieldName() from utils.ts
  • buildDefaultSelectLiteral() from select-helpers.ts
  • buildSelectFallbackExpr(), buildDefaultSelectExpr(), withoutFieldsSelectionType(), withoutFieldsListSelectionType(), NON_SELECT_TYPES_AST from hooks-ast.ts
  • buildDefaultSelectExpression() from orm/custom-ops-generator.ts
  • All const defaultSelect = ... declarations and Overload 2 (without fields) from all generators
  • defaultRef() helper and related fallback logic from orm/model-generator.ts

Net result: ~1,300 lines removed, 25 snapshots updated to reflect the simpler single-overload signatures.

Note: This PR is stacked on top of #693 (CLI cleanup) and #691 (AST regression fix). Those should be merged first, then this PR rebased.

Updates since last revision

  • Bumped makage from 0.1.100.1.12 across all 78 workspace packages. This picks up the ENOTEMPTY race condition fix (maxRetries: 3 on fs.rm in clean.ts) that was causing intermittent CI build failures in packages like pg-ast, csv-to-pg, etc.

Review & Testing Checklist for Human

  • Breaking change verification: Making selection/fields required is intentional but breaking. Any existing consumer code calling hooks without specifying fields will fail to compile. Confirm this is the desired behavior before merging.
  • Snapshot review: Verify the 25 updated snapshots only show removal of Overload 2 and defaultSelect references — no unintended logic changes. Whitespace/formatting differences from Babel AST output are expected.
  • ORM model methods: Spot-check that findMany, findFirst, findOne, create, update, delete all properly require select in their signatures (no optional fallback).
  • Custom ops generator: Verify removing the typeRegistry parameter from generateCustomQueryOpsFile/generateCustomMutationOpsFile doesn't break anything (it was only used for building default selects).
  • Test plan: Run pnpm build && pnpm test in graphql/codegen — all 204 tests should pass. CI should now pass with makage 0.1.12.

Notes

yyyyaaa and others added 9 commits February 6, 2026 01:59
…copy patterns

- Convert queries.ts, mutations.ts, custom-queries.ts, custom-mutations.ts from lines.push() string concatenation to Babel AST generation
- Convert client.ts and selection.ts from string template literals to template-copy pattern
- Add hooks-ast.ts shared helper library for Babel AST node construction
- Add template files: hooks-client.ts, hooks-selection.ts
- Add AGENTS.md with codegen rules (AST-only, no string concat, templates as files)
- Update test snapshots for Babel formatting changes (whitespace/formatting only)
…-browser-compatible

- Add hyphenateKeys, flattenDbFields, buildDbConfig, seedArgvFromConfig,
  buildGenerateOptions to shared.ts as generic reusable utilities
- Replace manual cliOverrides/hasNonInteractiveArgs with prompt->camelize->generate flow
- Remove deprecated --browser-compatible flag from CLI, config types, and generate
- Simplify both CLI entry points (graphql/codegen/src/cli, packages/cli)
- Update test mocks to match new shared utility imports
- Remove all defaultSelect constants and overload 2 (without fields) from all hook generators
- Remove buildDefaultSelectExpr, buildSelectFallbackExpr, buildDefaultSelectLiteral, getDefaultSelectFieldName
- Remove withoutFieldsSelectionType, withoutFieldsListSelectionType, NON_SELECT_TYPES_AST
- Remove buildDefaultSelectExpression from ORM custom-ops-generator
- Remove defaultSelect/defaultRef from ORM model-generator
- Make selection with fields required in all hook and ORM method signatures
- Update 25 snapshots to reflect removed overloads
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants