✨ Add basic graphql API using strawberry 🍓
✨ Add allProducts query
This commit is contained in:
1 parent
e2db9052bc
commit
fa89353525
12 files changed
+215
-114
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import strawberry
|
||||
from strawberry_django import auto
|
||||
|
||||
from main import models
|
||||
|
||||
|
||||
@strawberry.django.type(models.Product)
|
||||
class Product:
|
||||
id: auto
|
||||
name: auto
|
||||
sale_price_int: auto
|
||||
sale_price_ext: auto
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class Query:
|
||||
all_products: list[Product] = strawberry.django.field()
|
||||
|
||||
|
||||
schema = strawberry.Schema(query=Query)
|
||||
Reference in new issue
Block a user