Skip to content

Commit d4e8cbd

Browse files
committed
Add fragment search support to list collections and add tests
1 parent 5a23221 commit d4e8cbd

3 files changed

Lines changed: 382 additions & 2 deletions

File tree

datajunction-server/datajunction_server/api/graphql/queries/collections.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818

1919
async def list_collections(
20+
fragment: Annotated[
21+
str | None,
22+
strawberry.argument(
23+
description="Search fragment to filter collections by name or description",
24+
),
25+
] = None,
2026
created_by: Annotated[
2127
str | None,
2228
strawberry.argument(
@@ -31,7 +37,7 @@ async def list_collections(
3137
info: Info,
3238
) -> list[Collection]:
3339
"""
34-
List collections, optionally filtered by creator.
40+
List collections, optionally filtered by fragment, creator, or limit.
3541
"""
3642
session = info.context["session"]
3743

@@ -57,6 +63,13 @@ async def list_collections(
5763
)
5864
)
5965

66+
# Filter by fragment (search in name or description)
67+
if fragment:
68+
statement = statement.where(
69+
(DBCollection.name.ilike(f"%{fragment}%"))
70+
| (DBCollection.description.ilike(f"%{fragment}%")),
71+
)
72+
6073
if created_by:
6174
statement = statement.join(
6275
User,

datajunction-server/datajunction_server/api/graphql/schema.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ type Query {
598598

599599
"""List collections, optionally filtered by creator (for My Workspace)."""
600600
listCollections(
601+
"""Search fragment to filter collections by name or description"""
602+
fragment: String = null
603+
601604
"""Filter to collections created by this user"""
602605
createdBy: String = null
603606

0 commit comments

Comments
 (0)