Repository navigation
fix(codegen): create is optional like update/delete - #1986
Conversation
…ook, model method, CLI command or docs for a table without one
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟡 2 medium 📍 Findings outside the diff (2) — 🟡 2 medium — defects on lines GitHub can't attach comments to🟡 Medium — Widen stale inline // graphql/query/src/introspect/transform-schema.ts
347 create: string;
🟡 Medium — Multi-target skill refs omit the create guard · docs-generator.ts:1219–1250 · // graphql/codegen/src/core/codegen/cli/docs-generator.ts
1219 `${toolName} ${cmd} create ${createFlags}`,
1220 `${toolName} ${cmd} update --${pk.name} <${cleanTypeName(pk.gqlType)}> ${editableFields.map((f) => `[--${f.name} <${cleanTypeName(f.type.gqlType)}>]`).join(' ')}`,
1221 `${toolName} ${cmd} delete --${pk.name} <${cleanTypeName(pk.gqlType)}>`,
1222 ],
1223 examples: [
1224 {
1225 description: `List ${singularName} records`,
1226 code: [`${toolName} ${cmd} list`],
1227 },
1228 {
1229 description: `List ${singularName} records with pagination`,
1230 code: [`${toolName} ${cmd} list --limit 10 --offset 0`],The PR guards The change widens
Reviewed commit: 62c6315 |
Summary
Table inference fabricated a create mutation name when the schema had none:
so a table whose create is hidden (e.g. a storage
filestable, whereupload<Files>is the only way a row is created — constructive-db#4335) still got acreate*ORM method,useCreate*Mutationhook, CLIcreatesubcommand and docs/skills, all calling a mutation that does not exist.update/deletewere already nullable;createnow follows the same rule:graphql/query:createnullable; the create op is only registered/generated when present.graphql/codegen:hasCreateMutation(table)gates the create hook + its barrel export, the ORM modelcreatemethod (and m2nadd<Relation>when the junction has no create), the CLIcreatesubcommand/handler, and the CLI/ORM/hooks docs.Unit tests:
infer-tablesreturnscreate: nullfor a table without a create mutation; the model generator emitsupdate/deletebut nocreatefor it.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