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 (#2145)
  • Loading branch information
thomasdax98 committed Jun 5, 2024
1 parent 16ffa7b commit 6717682
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 @@ -40,6 +40,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 @@ -88,6 +88,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 6717682

Please sign in to comment.