Skip to content

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

Allow to fetch collection background image with thumbnail

Artur Smęt25dfd6130cf4
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index c7f6646e94..af3e6307fe 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -351,6 +351,21 @@ class ProductType(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 Collection(CountableDjangoObjectType):
products = gql_optimizer.field(
PrefetchingConnectionField(
@@ -374,21 +389,6 @@ 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(