Skip to content

Commit 64c1d42

Browse files
committed
Refactor code
1 parent 0135cc2 commit 64c1d42

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

apps/common/dataloaders.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import typing
32

43
from django.db import models

apps/etl/dataloaders.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
21
import typing
32

43
from asgiref.sync import sync_to_async
4+
from common.dataloaders import load_model_objects
55
from django.utils.functional import cached_property
66
from strawberry.dataloader import DataLoader
77

8-
from common.dataloaders import load_model_objects
9-
108
from .models import User
119

1210
if typing.TYPE_CHECKING:

apps/etl/queries.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import strawberry
2-
from strawberry.types import Info
32
from asgiref.sync import sync_to_async
3+
from strawberry.types import Info
44

55
from apps.common.types import UserMeType
66
from apps.etl.types import ExtractionDataType
77
from main.graphql.paginations import CountList, pagination_field
8+
89
from .filters import ExtractionDataFilter
910

1011

main/graphql/dataloaders.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
from django.utils.functional import cached_property
2-
3-
4-
51
class GlobalDataLoader:
62
pass

main/graphql/schema.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import strawberry
2-
32
from strawberry.django.views import AsyncGraphQLView
3+
44
from apps.etl import queries as etl_queries
5-
from .permission import IsAuthenticated
6-
from .dataloaders import GlobalDataLoader
75

86
from .context import GraphQLContext
7+
from .dataloaders import GlobalDataLoader
8+
from .permission import IsAuthenticated
99

1010

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

1919

2020
@strawberry.type
21-
class PublicQuery(
22-
):
21+
class PublicQuery:
2322
id: strawberry.ID = strawberry.ID("public")
2423

2524

2625
@strawberry.type
27-
class PrivateQuery(
28-
etl_queries.PrivateQuery
29-
):
26+
class PrivateQuery(etl_queries.PrivateQuery):
3027
id: strawberry.ID = strawberry.ID("private")
3128

3229

3330
@strawberry.type
34-
class PublicMutation(
35-
):
31+
class PublicMutation:
3632
id: strawberry.ID = strawberry.ID("public")
3733

3834

3935
@strawberry.type
40-
class PrivateMutation(
41-
):
36+
class PrivateMutation:
4237
id: strawberry.ID = strawberry.ID("private")
4338

4439

4540
@strawberry.type
4641
class Query:
4742
public: PublicQuery = strawberry.field(resolver=lambda: PublicQuery())
48-
private: PrivateQuery = strawberry.field(
49-
permission_classes=[IsAuthenticated],
50-
resolver=lambda: PrivateQuery()
51-
)
43+
private: PrivateQuery = strawberry.field(permission_classes=[IsAuthenticated], resolver=lambda: PrivateQuery())
5244

5345

5446
@strawberry.type

0 commit comments

Comments
 (0)