mirror of
https://github.com/makeplane/plane.git
synced 2026-07-14 06:25:58 +02:00
[MOBIL-707] chore: update instance version details and enforce minimum supported backend version (#2414)
* chore: current instance query and updated the min self hosted version * chore: typo and handled version data optional
This commit is contained in:
29
apiserver/plane/graphql/queries/instance.py
Normal file
29
apiserver/plane/graphql/queries/instance.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Third-Party Imports
|
||||
import strawberry
|
||||
|
||||
# Python Standard Library Imports
|
||||
from asgiref.sync import sync_to_async
|
||||
|
||||
# Strawberry Imports
|
||||
from strawberry.types import Info
|
||||
from strawberry.exceptions import GraphQLError
|
||||
|
||||
# Module Imports
|
||||
from plane.graphql.permissions.public import public_query
|
||||
from plane.graphql.types.instance import InstanceType
|
||||
from plane.license.models import Instance
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class InstanceQuery:
|
||||
@strawberry.field
|
||||
@public_query()
|
||||
async def instance(self, info: Info) -> InstanceType:
|
||||
instance = await sync_to_async(Instance.objects.first)()
|
||||
|
||||
if not instance:
|
||||
message = "Instance not found"
|
||||
error_extensions = {"code": "INSTANCE_NOT_FOUND", "statusCode": 404}
|
||||
raise GraphQLError(message, extensions=error_extensions)
|
||||
|
||||
return instance
|
||||
@@ -44,4 +44,7 @@ class VersionCheckQuery:
|
||||
min_supported_version=version_details["min_supported_version"],
|
||||
url=version_details["url"],
|
||||
force_update=version_details["force_update"],
|
||||
min_supported_backend_version=version_details[
|
||||
"min_backend_supported_version"
|
||||
],
|
||||
)
|
||||
|
||||
@@ -53,6 +53,7 @@ from .queries.feature_flag import FeatureFlagQuery
|
||||
from .queries.version_check import VersionCheckQuery
|
||||
from .queries.timezone import TimezoneListQuery
|
||||
from .queries.asset import WorkspaceAssetQuery, ProjectAssetQuery
|
||||
from .queries.instance import InstanceQuery
|
||||
|
||||
# mutations
|
||||
from .mutations.workspace import WorkspaceMutation, WorkspaceInviteMutation
|
||||
@@ -151,6 +152,7 @@ class Query(
|
||||
TimezoneListQuery,
|
||||
WorkspaceAssetQuery,
|
||||
ProjectAssetQuery,
|
||||
InstanceQuery,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
12
apiserver/plane/graphql/types/instance.py
Normal file
12
apiserver/plane/graphql/types/instance.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Strawberry imports
|
||||
import strawberry_django
|
||||
|
||||
# Module Imports
|
||||
from plane.license.models import Instance
|
||||
|
||||
|
||||
@strawberry_django.type(Instance)
|
||||
class InstanceType:
|
||||
instance_name: str
|
||||
current_version: str
|
||||
latest_version: str
|
||||
@@ -1,10 +1,14 @@
|
||||
# Python imports
|
||||
from typing import Optional
|
||||
|
||||
# Strawberry imports
|
||||
import strawberry
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class VersionCheckType:
|
||||
version: str
|
||||
min_supported_version: str
|
||||
url: str
|
||||
version: Optional[str]
|
||||
min_supported_version: Optional[str]
|
||||
url: Optional[str]
|
||||
force_update: bool
|
||||
min_supported_backend_version: Optional[str]
|
||||
|
||||
@@ -12,7 +12,6 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
from asgiref.sync import sync_to_async
|
||||
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||
from rest_framework_simplejwt.exceptions import InvalidToken, TokenError
|
||||
from graphql import parse
|
||||
|
||||
# Strawberry imports
|
||||
from strawberry.django.views import AsyncGraphQLView
|
||||
@@ -98,7 +97,7 @@ class CustomGraphQLView(AsyncGraphQLView):
|
||||
return None
|
||||
|
||||
def is_public_operation(self, query_name: str) -> bool:
|
||||
auth_neglect_list = ["VersionCheckQuery"]
|
||||
auth_neglect_list = ["VersionCheckQuery", "InstanceQuery"]
|
||||
|
||||
if query_name in auth_neglect_list:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user