Skip to content

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

Handle product resolver case when there are no variants

Tomasz Szymanski1a5203e65741
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index dc8a769288..012a3846a4 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -512,6 +512,10 @@ class Product(CountableDjangoObjectType):
@staticmethod
def resolve_default_variant(root: models.Product, info):
+ default_variant_id = root.default_variant_id
+ if default_variant_id is None:
+ return None
+
return ProductVariantByIdLoader(info.context).load(root.default_variant_id)
@staticmethod