Skip to content

Commit 60b001d

Browse files
committed
add collaborative by slug query
1 parent 1441084 commit 60b001d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

api/schema/collaborative_schema.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ def contributors_by_collaborative(
197197
f"Collaborative with ID {collaborative_id} does not exist."
198198
)
199199

200+
@strawberry_django.field
201+
@trace_resolver(
202+
name="get_collaborative_by_slug",
203+
attributes={"component": "collaborative"},
204+
)
205+
def collaborative_by_slug(self, info: Info, slug: str) -> TypeCollaborative:
206+
try:
207+
collaborative = Collaborative.objects.get(slug=slug)
208+
return TypeCollaborative.from_django(collaborative)
209+
except Collaborative.DoesNotExist:
210+
raise ValueError(f"Collaborative with slug {slug} does not exist.")
211+
200212

201213
@trace_resolver(
202214
name="update_collaborative_tags", attributes={"component": "collaborative"}

0 commit comments

Comments
 (0)