Skip to content

Commit b004563

Browse files
authored
Merge pull request #170 from mapswipe/feat/public-api
feat(query): add public endpoints for queries
2 parents cb18c16 + a7247e0 commit b004563

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

apps/project/graphql/queries.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def default_custom_options(self, project_type: ProjectTypeEnum) -> list[CustomOp
8080

8181
# Private --------------------
8282
project: ProjectType = strawberry_django.field(extensions=[IsAuthenticated()])
83+
public_project: ProjectType = strawberry_django.field()
8384

8485
project_asset: ProjectAssetType = strawberry_django.field(extensions=[IsAuthenticated()])
8586

@@ -91,6 +92,7 @@ def default_custom_options(self, project_type: ProjectTypeEnum) -> list[CustomOp
9192
)
9293

9394
organization: OrganizationType = strawberry_django.field(extensions=[IsAuthenticated()])
95+
public_organization: OrganizationType = strawberry_django.field()
9496

9597
# --- Paginated
9698
@strawberry_django.offset_paginated(
@@ -108,6 +110,16 @@ def organizations(
108110
return Organization.objects.all()
109111
return Organization.objects.exclude(is_archived=True).all()
110112

113+
@strawberry_django.offset_paginated(
114+
OffsetPaginated[OrganizationType],
115+
order=OrganizationOrder,
116+
filters=OrganizationFilter,
117+
)
118+
def public_organizations(
119+
self,
120+
) -> QuerySet[Organization]:
121+
return Organization.objects.exclude(is_archived=True).all()
122+
111123
# --- Paginated
112124
@strawberry_django.offset_paginated(
113125
OffsetPaginated[ProjectType],
@@ -129,3 +141,18 @@ def projects(
129141
Project.Status.PAUSED,
130142
],
131143
).all()
144+
145+
@strawberry_django.offset_paginated(
146+
OffsetPaginated[ProjectType],
147+
order=ProjectOrder,
148+
filters=ProjectFilter,
149+
)
150+
def public_projects(
151+
self,
152+
) -> QuerySet[Project]:
153+
return Project.objects.filter(
154+
status__in=[
155+
Project.Status.FINISHED,
156+
Project.Status.PUBLISHED,
157+
],
158+
).all()

schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,10 @@ type Query {
20272027
projectAsset(id: ID!): ProjectAssetType! @isAuthenticated
20282028
projectAssets(pagination: OffsetPaginationInput, filters: ProjectAssetFilter, order: ProjectAssetOrder): ProjectAssetTypeOffsetPaginated! @isAuthenticated
20292029
projects(includeAll: Boolean! = false, filters: ProjectFilter, order: ProjectOrder, pagination: OffsetPaginationInput): ProjectTypeOffsetPaginated! @isAuthenticated
2030+
publicOrganization(id: ID!): OrganizationType!
2031+
publicOrganizations(filters: OrganizationFilter, order: OrganizationOrder, pagination: OffsetPaginationInput): OrganizationTypeOffsetPaginated!
2032+
publicProject(id: ID!): ProjectType!
2033+
publicProjects(filters: ProjectFilter, order: ProjectOrder, pagination: OffsetPaginationInput): ProjectTypeOffsetPaginated!
20302034
tileServers: RasterTileServersType! @isAuthenticated
20312035
tutorial(id: ID!): TutorialType! @isAuthenticated
20322036
tutorialAsset(id: ID!): TutorialAssetType! @isAuthenticated

0 commit comments

Comments
 (0)