Skip to content

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

Allow to fetch category background image with thumbnail

Artur Smęta04cfb8fff76
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index 395d185545..c7f6646e94 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -374,6 +374,21 @@ class Collection(CountableDjangoObjectType):
return gql_optimizer.query(qs, info)
+class ImageWithThumbnail(graphene.ObjectType):
+ url = graphene.String(
+ required=True,
+ description='The URL of the image.',
+ size=graphene.Int(description='Size of the image'))
+
+ class Meta:
+ description = 'Represents an image.'
+
+ def resolve_url(self, info, size=None):
+ if size:
+ return get_thumbnail(self, size)
+ return self.url
+
+
class Category(CountableDjangoObjectType):
products = gql_optimizer.field(
PrefetchingConnectionField(