Skip to content

Commit f10f2d2

Browse files
committed
remove pagination from decorator
1 parent d59bf56 commit f10f2d2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

api/schema/usecase_schema.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ def use_cases(
126126

127127
return TypeUseCase.from_django_list(queryset)
128128

129-
@strawberry_django.field(
130-
filters=UseCaseFilter,
131-
order=UseCaseOrder,
132-
)
129+
@strawberry_django.field
133130
@trace_resolver(name="get_published_use_cases", attributes={"component": "usecase"})
134131
def published_use_cases(
135132
self,
@@ -141,23 +138,28 @@ def published_use_cases(
141138
"""Get published use cases."""
142139
queryset = UseCase.objects.filter(status=UseCaseStatus.PUBLISHED)
143140

141+
# Apply filters first
144142
if filters is not strawberry.UNSET:
145143
queryset = strawberry_django.filters.apply(filters, queryset, info)
146144

145+
# Apply ordering
147146
if order is not strawberry.UNSET:
148147
queryset = strawberry_django.ordering.apply(order, queryset, info)
149148

150-
# Apply pagination
149+
# Convert to list to avoid any slicing conflicts
150+
results = list(queryset)
151+
152+
# Apply pagination on the list
151153
if pagination is not strawberry.UNSET:
152154
offset = getattr(pagination, "offset", 0) or 0
153155
limit = getattr(pagination, "limit", None)
154156

155157
if limit is not None:
156-
queryset = queryset[offset : offset + limit]
158+
results = results[offset : offset + limit]
157159
elif offset > 0:
158-
queryset = queryset[offset:]
160+
results = results[offset:]
159161

160-
return TypeUseCase.from_django_list(queryset)
162+
return TypeUseCase.from_django_list(results)
161163

162164
@strawberry_django.field
163165
@trace_resolver(

0 commit comments

Comments
 (0)