Skip to content

Commit 0bb9e11

Browse files
rabbits changes
Signed-off-by: NishantSinghhhhh <[email protected]>
1 parent 04eba4f commit 0bb9e11

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/graphql/types/Mutation/updateActionItemCategory.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const mutationUpdateActionItemCategoryArgumentsSchema = z.object({
1313
}),
1414
});
1515

16-
builder.mutationField("updateActionItemCategory", (t) =>
16+
export const updateActionItemCategory = builder.mutationField("updateActionItemCategory", (t) =>
1717
t.field({
1818
type: ActionItemCategory,
1919
args: {
@@ -85,17 +85,27 @@ builder.mutationField("updateActionItemCategory", (t) =>
8585
});
8686
}
8787

88-
// 5. Update the category
89-
// Build a "set" object only with provided fields
90-
const updates: Record<string, unknown> = { updatedAt: new Date() };
88+
// Build update fields
89+
const updates: Record<string, unknown> = {};
90+
let hasUpdates = false;
91+
9192
if (typeof name === "string") {
92-
updates.name = name;
93+
updates.name = name;
94+
hasUpdates = true;
9395
}
96+
9497
if (typeof isDisabled === "boolean") {
95-
updates.isDisabled = isDisabled;
98+
updates.isDisabled = isDisabled;
99+
hasUpdates = true;
96100
}
97101

98-
// ...
102+
// Only update if there's any field to update.
103+
if (hasUpdates) {
104+
updates.updatedAt = new Date();
105+
// Proceed with the update operation
106+
} else {
107+
// Optionally log or handle no-op scenario: nothing to update
108+
}
99109

100110
const [updatedCategory] = await ctx.drizzleClient
101111
.update(actionCategoriesTable)

0 commit comments

Comments
 (0)