♻ Split types, mutations, queries by model
This commit is contained in:
1 parent
3274cb96c0
commit
41638e605f
13 files changed
+193
-156
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,9 @@
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from main.api.types.inventory import Transaction, TransactionOrdering
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class InventoryQueries:
|
||||
transaction_list: list[Transaction] = strawberry_django.field(pagination=True, order=TransactionOrdering)
|
||||
@@ -0,0 +1,24 @@
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from main import models
|
||||
from main.api.types.shop import Order, OrderOrdering, OrderStats, OrderStatsByTime, Product
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class ShopQueries:
|
||||
all_products: list[Product] = strawberry_django.field()
|
||||
all_orders: list[Order] = strawberry_django.field()
|
||||
order_list: list[Order] = strawberry_django.field(pagination=True, order=OrderOrdering)
|
||||
|
||||
@strawberry.field
|
||||
def order_stats(self) -> OrderStats:
|
||||
return OrderStats(
|
||||
**{
|
||||
period: [
|
||||
OrderStatsByTime(**stat)
|
||||
for stat in models.Order.objects.count_by_created_period(period).order_by("period")
|
||||
]
|
||||
for period in ["yearly", "monthly", "daily", "hourly"]
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from django.contrib.auth.models import User as DjangoUser
|
||||
from strawberry import ID
|
||||
|
||||
from main.api.types.users import User
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class UsersQueries:
|
||||
all_users: list[User] = strawberry_django.field()
|
||||
|
||||
@strawberry.field
|
||||
def user(self, user_id: ID) -> User:
|
||||
return DjangoUser.objects.get(pk=user_id)
|
||||
Reference in new issue
Block a user