diff --git a/.changeset/lemon-eyes-kick.md b/.changeset/lemon-eyes-kick.md new file mode 100644 index 0000000000..0218b7330b --- /dev/null +++ b/.changeset/lemon-eyes-kick.md @@ -0,0 +1,5 @@ +--- +"@comet/cms-api": patch +--- + +API CrudSingleGenerator: Run `transformToBlockData()` for block fields on create diff --git a/demo/api/src/footer/generated/footer.resolver.ts b/demo/api/src/footer/generated/footer.resolver.ts index 3df39e0039..8a8f2b6f6e 100644 --- a/demo/api/src/footer/generated/footer.resolver.ts +++ b/demo/api/src/footer/generated/footer.resolver.ts @@ -39,6 +39,7 @@ export class FooterResolver { if (!footer) { footer = this.repository.create({ ...input, + content: input.content.transformToBlockData(), scope, }); } else if (lastUpdatedAt) { diff --git a/packages/api/cms-api/src/generator/generate-crud-single.ts b/packages/api/cms-api/src/generator/generate-crud-single.ts index 0e7994b9a6..e159058736 100644 --- a/packages/api/cms-api/src/generator/generate-crud-single.ts +++ b/packages/api/cms-api/src/generator/generate-crud-single.ts @@ -86,6 +86,7 @@ export async function generateCrudSingle(generatorOptions: CrudSingleGeneratorOp if (!${instanceNameSingular}) { ${instanceNameSingular} = this.repository.create({ ...input, + ${blockProps.length ? `${blockProps.map((prop) => `${prop.name}: input.${prop.name}.transformToBlockData()`).join(", ")}, ` : ""} ${scopeProp ? `scope,` : ""} }); } else if (lastUpdatedAt) {