Slide 13
Slide 13 text
Types
# types.py
from graphene_django import DjangoObjectType
class Product(DjangoObjectType):
price = graphene.Field(Money, description="Price of a product.")
class Meta:
description = "Represents a product."
model = models.Product
only_fields = [
"name",
"description",
"is_published",
"updated_at",
]
@staticmethod
def resolve_price(root: models.Product, *_):
return Money(amount=root.price, currency=settings.DEFAULT_CURRENCY)
@maarcingebala 13