Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Turn Product Attribtues and Variant Attributes into a flat list

Pacu2b2b2fc198681
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index 712c86a01c..b3af2db2c1 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -254,6 +254,10 @@ class ProductType(CountableDjangoObjectType):
filterset_class=ProductFilterSet,
description='List of products of this type.')
tax_rate = TaxRateType(description='A type of tax rate.')
+ variant_attributes = graphene.List(
+ Attribute, description='Variant attributes of that product type.')
+ product_attributes = graphene.List(
+ Attribute, description='Product attributes of that product type.')
class Meta:
description = """Represents a type of product. It defines what
@@ -267,6 +271,12 @@ class ProductType(CountableDjangoObjectType):
return products_with_details(
user=user).filter(product_type=self).distinct()
+ def resolve_variant_attributes(self, info):
+ return self.variant_attributes.prefetch_related('values')
+
+ def resolve_product_attributes(self, info):
+ return self.product_attributes.prefetch_related('values')
+
class Collection(CountableDjangoObjectType):
products = DjangoFilterConnectionField(