Repository navigation
fix(codegen): a table without a create mutation has no Create<Table>Input, bulkCreate or bulkUpsert anywhere - #1988
Conversation
…mmand of a table without a create mutation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change updates two GraphQL codegen generators so that tables lacking a create mutation no longer emit a create command or import the corresponding
Reviewed commit: fb73284 |
There was a problem hiding this comment.
This PR makes the CLI command generator and ORM model generator skip the create-command/import and CreateInput type when a table has no create mutation, but the ORM generator's remaining code paths still reference the omitted type.
Key findings
- 🟡 bulkCreate/bulkUpsert still reference omitted
Create<T>Input— model-generator.ts:268
…m the schema when the table has no create mutation
…kUpsert; generated ORM for it type-checks
Summary
Follow-up to #1986. That PR stopped emitting
Create<Table>Inputininput-types.tswhentable.query.create === null. But the rest of the generated output still referenced it, so it no longer type-checked. constructive-db's regenerated storagefile.ts/platformFile.tshit this.Create<Table>Inputare now gated on create.Create<Table>Input, so a create-less table has neither. NewgetBulkInsertMutationName(table)/getBulkUpsertMutationName(table)inutils.tsreturnnullwithout create. Every generator that readquery.bulkInsert/bulkUpsertnow goes through them: ORM model + docs, hooks, mutation keys, CLI commands + docs.buildTableCrudTypeNamesno longer reservesCreate<Table>Inputfor a create-less table. A custom mutation that owns that name (e.g.createPrincipal(input: CreatePrincipalInput)) now gets it generated from the schema. Before this, it was dropped, and before fix(codegen): create is optional like update/delete #1986 it was emitted with the table's shape.Tests:
orm-typecheck.test.tsgenerates the full ORM for a create-less table that hasbulkInsert/bulkUpsertand type-checks it withts.createProgram. On the previous head it fails withCannot find name 'CreateFileInput'.Link to Devin session: https://app.devin.ai/sessions/7ffa2e370d49424bb81161cc2390ba12
Open in Devin Desktop: https://app.devin.ai/desktop/session/7ffa2e370d49424bb81161cc2390ba12?variant=devin
Requested by: @pyramation