Skip to content

Commit

Permalink
API CrudSingleGenerator: Run transformToBlockData() for block field…
Browse files Browse the repository at this point in the history
…s on create (v5) (#2640)

Co-authored-by: Thomas Dax <[email protected]>
  • Loading branch information
beelee and thomasdax98 authored Oct 21, 2024
1 parent ecfe360 commit b6048d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-eyes-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-api": patch
---

API CrudSingleGenerator: Run `transformToBlockData()` for block fields on create
1 change: 1 addition & 0 deletions demo/api/src/footer/generated/footer.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class FooterResolver {
if (!footer) {
footer = this.repository.create({
...input,
content: input.content.transformToBlockData(),
scope,
});
} else if (lastUpdatedAt) {
Expand Down
1 change: 1 addition & 0 deletions packages/api/cms-api/src/generator/generate-crud-single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b6048d7

Please sign in to comment.