Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Dec 31, 2024
1 parent 0135cc2 commit 64c1d42
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
1 change: 0 additions & 1 deletion apps/common/dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import typing

from django.db import models
Expand Down
4 changes: 1 addition & 3 deletions apps/etl/dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

import typing

from asgiref.sync import sync_to_async
from common.dataloaders import load_model_objects
from django.utils.functional import cached_property
from strawberry.dataloader import DataLoader

from common.dataloaders import load_model_objects

from .models import User

if typing.TYPE_CHECKING:
Expand Down
3 changes: 2 additions & 1 deletion apps/etl/queries.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import strawberry
from strawberry.types import Info
from asgiref.sync import sync_to_async
from strawberry.types import Info

from apps.common.types import UserMeType
from apps.etl.types import ExtractionDataType
from main.graphql.paginations import CountList, pagination_field

from .filters import ExtractionDataFilter


Expand Down
4 changes: 0 additions & 4 deletions main/graphql/dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
from django.utils.functional import cached_property



class GlobalDataLoader:
pass
24 changes: 8 additions & 16 deletions main/graphql/schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import strawberry

from strawberry.django.views import AsyncGraphQLView

from apps.etl import queries as etl_queries
from .permission import IsAuthenticated
from .dataloaders import GlobalDataLoader

from .context import GraphQLContext
from .dataloaders import GlobalDataLoader
from .permission import IsAuthenticated


class CustomAsyncGraphQLView(AsyncGraphQLView):
Expand All @@ -18,37 +18,29 @@ async def get_context(self, *args, **kwargs) -> GraphQLContext:


@strawberry.type
class PublicQuery(
):
class PublicQuery:
id: strawberry.ID = strawberry.ID("public")


@strawberry.type
class PrivateQuery(
etl_queries.PrivateQuery
):
class PrivateQuery(etl_queries.PrivateQuery):
id: strawberry.ID = strawberry.ID("private")


@strawberry.type
class PublicMutation(
):
class PublicMutation:
id: strawberry.ID = strawberry.ID("public")


@strawberry.type
class PrivateMutation(
):
class PrivateMutation:
id: strawberry.ID = strawberry.ID("private")


@strawberry.type
class Query:
public: PublicQuery = strawberry.field(resolver=lambda: PublicQuery())
private: PrivateQuery = strawberry.field(
permission_classes=[IsAuthenticated],
resolver=lambda: PrivateQuery()
)
private: PrivateQuery = strawberry.field(permission_classes=[IsAuthenticated], resolver=lambda: PrivateQuery())


@strawberry.type
Expand Down

0 comments on commit 64c1d42

Please sign in to comment.