Skip to content

Commit 305febe

Browse files
committed
feat(organization): Set default filtering on organization query
1 parent ccdf978 commit 305febe

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

apps/project/graphql/queries.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from strawberry_django.pagination import OffsetPaginated
55
from strawberry_django.permissions import IsAuthenticated
66

7-
from apps.project.models import Project
7+
from apps.project.models import Organization, Project
88
from utils.geo.raster_tile_server.config import RasterConfig, RasterTileServerNameEnum, RasterTileServerNameEnumWithoutCustom
99
from utils.geo.vector_tile_server.config import VectorConfig, VectorTileServerNameEnum, VectorTileServerNameEnumWithoutCustom
1010

@@ -71,11 +71,19 @@ class Query:
7171
organization: OrganizationType = strawberry_django.field(extensions=[IsAuthenticated()])
7272

7373
# --- Paginated
74-
organizations: OffsetPaginated[OrganizationType] = strawberry_django.offset_paginated(
74+
@strawberry_django.offset_paginated(
75+
OffsetPaginated[OrganizationType],
7576
order=OrganizationOrder,
7677
filters=OrganizationFilter,
7778
extensions=[IsAuthenticated()],
7879
)
80+
def organizations(
81+
self,
82+
include_all: bool = False,
83+
) -> QuerySet[Organization]:
84+
if include_all:
85+
return Organization.objects.all()
86+
return Organization.objects.exclude(is_archived=True).all()
7987

8088
# --- Paginated
8189
@strawberry_django.offset_paginated(

schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ type Query {
15271527
projectAsset(id: ID!): ProjectAssetType! @isAuthenticated
15281528
projectAssets(pagination: OffsetPaginationInput, filters: ProjectAssetFilter, order: ProjectAssetOrder): ProjectAssetTypeOffsetPaginated! @isAuthenticated
15291529
organization(id: ID!): OrganizationType! @isAuthenticated
1530-
organizations(pagination: OffsetPaginationInput, filters: OrganizationFilter, order: OrganizationOrder): OrganizationTypeOffsetPaginated! @isAuthenticated
1530+
organizations(includeAll: Boolean! = false, filters: OrganizationFilter, order: OrganizationOrder, pagination: OffsetPaginationInput): OrganizationTypeOffsetPaginated! @isAuthenticated
15311531
projects(includeAll: Boolean! = false, filters: ProjectFilter, order: ProjectOrder, pagination: OffsetPaginationInput): ProjectTypeOffsetPaginated! @isAuthenticated
15321532
tutorial(id: ID!): TutorialType! @isAuthenticated
15331533
tutorials(includeAll: Boolean! = false, filters: TutorialFilter, order: TutorialOrder, pagination: OffsetPaginationInput): TutorialTypeOffsetPaginated! @isAuthenticated

0 commit comments

Comments
 (0)