Skip to content

Commit 3b642a9

Browse files
committed
add deletetags mutation
1 parent 48d2254 commit 3b642a9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

api/schema/tags_schema.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from strawberry.types import Info
44

55
from api.models import Tag
6+
from api.schema.base_mutation import BaseMutation
67
from api.utils.graphql_telemetry import trace_resolver
8+
from authorization.permissions import IsAuthenticated
79

810

911
@strawberry.type
@@ -22,3 +24,18 @@ def delete_tag(self, info: Info, tag_id: str) -> bool:
2224
raise ValueError(f"Tag with ID {tag_id} does not exist.")
2325
tag.delete()
2426
return True
27+
28+
@strawberry.mutation
29+
@BaseMutation.mutation(
30+
permission_classes=[IsAuthenticated],
31+
trace_name="delete_tags",
32+
trace_attributes={"component": "tag"},
33+
)
34+
def delete_tags(self, info: Info, tag_ids: list[str]) -> bool:
35+
"""Delete multiple tags."""
36+
try:
37+
tags = Tag.objects.filter(id__in=tag_ids)
38+
except Tag.DoesNotExist:
39+
raise ValueError(f"Tags with IDs {tag_ids} do not exist.")
40+
tags.delete()
41+
return True

0 commit comments

Comments
 (0)