Skip to content

Commit

Permalink
[shopsys] FE API: blog category now can return main image (#3475)
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin authored Oct 10, 2024
2 parents bf67acd + 2c8e364 commit 0c7df8d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Model/Resolver/Image/BlogCategoryImagesQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Shopsys\FrontendApiBundle\Model\Resolver\Image;

use GraphQL\Executor\Promise\Promise;
use Shopsys\FrameworkBundle\Model\Blog\Category\BlogCategory;

class BlogCategoryImagesQuery extends ImagesQuery
{
protected const string ENTITY_NAME = 'blogCategory';

/**
* @param \Shopsys\FrameworkBundle\Model\Blog\Category\BlogCategory $blogCategory
* @param string|null $type
* @return \GraphQL\Executor\Promise\Promise
*/
public function mainImageByBlogCategoryPromiseQuery(BlogCategory $blogCategory, ?string $type): Promise
{
return $this->mainImageByEntityIdPromiseQuery($blogCategory->getId(), static::ENTITY_NAME, $type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ BlogCategoryDecorator:
slug:
type: "String!"
description: "The blog category URL slug"
mainImage:
type: "Image"
description: "Blog category image"
resolve: '@=query("mainImageByBlogCategoryPromiseQuery", value, args["type"])'
args:
type:
type: "String"
defaultValue: null
breadcrumb:
type: "[Link!]!"
description: "Hierarchy of the current element in relation to the structure"
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ services:
$imagesBatchLoader: '@images_batch_loader'
$firstImageBatchLoader: '@first_image_batch_loader'

Shopsys\FrontendApiBundle\Model\Resolver\Image\BlogCategoryImagesQuery:
arguments:
$imagesBatchLoader: '@images_batch_loader'
$firstImageBatchLoader: '@first_image_batch_loader'

Shopsys\FrontendApiBundle\Model\Resolver\Image\ImagesQuery:
arguments:
$imagesBatchLoader: '@images_batch_loader'
Expand Down

0 comments on commit 0c7df8d

Please sign in to comment.