docs(plans): gqlorm remove db import injection plan#1702
Conversation
❌ Deploy Preview for cedarjs failed.
|
Greptile SummaryThis PR adds a new implementation plan document for removing the hardcoded
Confidence Score: 3/5Safe to merge as a docs-only PR, but the implementation sketch has a logic flaw that will cause a hard build error for aliased imports if followed as written. Only one file changed (a plan doc), so there is no runtime risk. However, the plan contains a P1 inconsistency: the getTopLevelDbBinding sketch doesn't handle aliased db imports despite the acceptance criteria and test cases explicitly requiring it. docs/implementation-plans/gqlorm-remove-db-import-injection-plan.md — specifically the getTopLevelDbBinding implementation sketch around lines 120–128. Important Files Changed
Reviews (1): Last reviewed commit: "docs(plans): add gqlorm remove db import..." | Re-trigger Greptile |
| --- | ||
|
|
||
| ## Changes | ||
|
|
||
| ### 1. Rewrite `babel-plugin-cedar-gqlorm-inject` to detect existing `db` binding | ||
|
|
||
| **File:** `packages/babel-config/src/plugins/babel-plugin-cedar-gqlorm-inject.ts` | ||
|
|
||
| **Current behavior:** The plugin unconditionally injects: |
There was a problem hiding this comment.
getTopLevelDbBinding won't find aliased imports
The sketch calls programPath.scope.getBinding('db'), which looks up a binding by its local identifier name. For import { db as prisma } from '@myorg/db', Babel registers the binding under prisma (the local name), not db. So getBinding('db') returns null, the plugin throws the hard error, and the aliased-import case silently breaks — directly contradicting test case 2 and the acceptance criteria ("The plugin handles aliased imports").
To support aliasing, traverse ImportDeclaration nodes and find any specifier whose imported.name === 'db', then return local.name as the identifier to use in the Object.assign call.
Adds implementation plan for removing the hardcoded
src/lib/dbimport from gqlorm's Babel plugin, replacing it with smart detection of the user's existingdbbinding.This is extracted from #1700