Skip to content

fix(codegen/cli): make autoEmbedWhere/autoEmbedInput generic in embedder template#1005

Merged
pyramation merged 1 commit intomainfrom
feat/auto-embed-generic-helpers
Apr 18, 2026
Merged

fix(codegen/cli): make autoEmbedWhere/autoEmbedInput generic in embedder template#1005
pyramation merged 1 commit intomainfrom
feat/auto-embed-generic-helpers

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

The generated embedder.ts template at graphql/codegen/src/core/codegen/templates/embedder.ts currently types autoEmbedWhere and autoEmbedInput to accept Record<string, unknown> — but the CLI codegen emits call sites that pass concrete generated *Filter / *Patch types (no index signature). ts-jest is lenient enough that downstream test runs stay green, but the strict tsc pass on lerna publish fails with ~74 TS2345 errors per consumer ("… is not assignable to parameter of type 'Record<string, unknown>'").

This was already patched directly on the generated file in constructive-io/agentic-db as part of unblocking their lerna publish (agentic-db#29). Without this upstream fix, the next pnpm generate:all in any consumer that uses the embedder helpers will regenerate the narrow signatures and re-break publish.

Fix: make both helpers generic, preserving the caller's concrete type and casting to Record<string, unknown> internally for field lookup. Runtime behavior is identical.

export async function autoEmbedWhere<T extends object>(
  where: T,
  vectorFieldNames: string[],
  embedder: EmbedderFunction,
): Promise<T> { /* unchanged body, typed through T */ }

export async function autoEmbedInput<T extends object>(
  data: T,
  vectorFieldNames: string[],
  embedder: EmbedderFunction,
): Promise<T> { /* unchanged body, typed through T */ }

Review & Testing Checklist for Human

  • Regenerate a consumer SDK (e.g. run pnpm generate:all in agentic-db against this branch) and confirm the regenerated embedder.ts matches the patch that landed in agentic-db PR Feat/test graphile #29.
  • Confirm lerna publish's strict tsc pass succeeds on a consumer that exercises autoEmbedWhere / autoEmbedInput call sites from CLI commands with concrete *Filter / *Patch types.

Notes

  • Template-only change; no runtime behavior difference and no change to EmbedderFunction or to the call-site codegen.
  • The same generic signature is already live in agentic-db at sdk/cli/generated/cli/embedder.ts, so this upstream change just prevents the next regen from reverting it.

Link to Devin session: https://app.devin.ai/sessions/fabecb6a46504fc293feca22d9cc91d4
Requested by: @pyramation

…der template

The CLI codegen emits calls like `findManyArgs.where = await autoEmbedWhere(findManyArgs.where ?? {}, ['embedding'], embedder)` and `await autoEmbedInput(cleanedData, ['embedding'], embedder)` where the first argument is a concrete `*Filter` / `*Patch` type produced by `input-types.ts`. Those generated types don't have a string index signature, so under strict `tsc` every call site errors with:

    error TS2345: Argument of type 'XxxFilter' is not assignable to
    parameter of type 'Record<string, unknown>'. Index signature for
    type 'string' is missing in type 'XxxFilter'.

CI for consumers (agentic-db et al.) passes via `ts-jest`, which is lenient about index-signature / excess-property checks, but `makage build` on publish is strict and fails across all generated `commands/*.ts` files.

Make both helpers generic (`<T extends object>(x: T, ...): Promise<T>`) and cast to `Record<string, unknown>` internally for the field-name indexing. Runtime behavior is unchanged (mutation in place, same return semantics), and call sites now type-check as-is without any generator change.

Consumer-side point fix already landed in constructive-io/agentic-db#29; this PR fixes the upstream template so the next `pnpm generate:all` in any consumer emits a correctly-typed `embedder.ts`.
@devin-ai-integration
Copy link
Copy Markdown
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

@pyramation pyramation merged commit eddc56b into main Apr 18, 2026
52 checks passed
@pyramation pyramation deleted the feat/auto-embed-generic-helpers branch April 18, 2026 10:11
devin-ai-integration bot pushed a commit to constructive-io/agentic-db that referenced this pull request Apr 18, 2026
…uctive-io/node to ^0.10.3, graphql-server-test to ^2.12.2

Picks up the upstream embedder template fix (constructive-io/constructive#1005)
so the next `pnpm generate:all` regenerates sdk/cli/generated/cli/embedder.ts
with the generic autoEmbedWhere/autoEmbedInput signatures already on main,
rather than the old narrow Record<string, unknown> shape that broke
lerna publish with 74 TS2345 errors.
devin-ai-integration bot pushed a commit to constructive-io/agentic-db that referenced this pull request Apr 18, 2026
…uctive-io/node to ^0.10.3, graphql-server-test to ^2.12.2

Picks up the upstream embedder template fix (constructive-io/constructive#1005)
so the next `pnpm generate:all` regenerates sdk/cli/generated/cli/embedder.ts
with the generic autoEmbedWhere/autoEmbedInput signatures already on main,
rather than the old narrow Record<string, unknown> shape that broke
lerna publish with 74 TS2345 errors.
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.

1 participant