Skip to content

Commit

Permalink
IBX-4415: Fixed createDomainContent mutation (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 authored Feb 15, 2023
1 parent 0ea6ebc commit c5b618b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/graphql/Item.types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AbstractItem:
_contentInfo:
description: 'Underlying content info item'
type: Content
resolve: '@=value.getContentInfo()'
resolve: '@=value.getContent().contentInfo'
_location:
description: 'Main location'
type: Location
Expand Down
18 changes: 14 additions & 4 deletions src/lib/Resolver/DomainContentMutationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
use Ibexa\Contracts\Core\Repository\Values as RepositoryValues;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
use Ibexa\GraphQL\Exception\UnsupportedFieldTypeException;
use Ibexa\GraphQL\ItemFactory;
use Ibexa\GraphQL\Schema\Domain\Content\NameHelper;
use Ibexa\GraphQL\Value\Item;
use Overblog\GraphQLBundle\Definition\Argument;
use Overblog\GraphQLBundle\Error\UserErrors;
use Overblog\GraphQLBundle\Relay\Node\GlobalId;
Expand All @@ -38,11 +40,19 @@ class DomainContentMutationResolver
*/
private $nameHelper;

public function __construct(API\Repository $repository, array $fieldInputHandlers, NameHelper $nameHelper)
{
/** @var \Ibexa\GraphQL\ItemFactory */
private $itemFactory;

public function __construct(
API\Repository $repository,
array $fieldInputHandlers,
NameHelper $nameHelper,
ItemFactory $relatedContentItemFactory
) {
$this->repository = $repository;
$this->fieldInputHandlers = $fieldInputHandlers;
$this->nameHelper = $nameHelper;
$this->itemFactory = $relatedContentItemFactory;
}

public function updateDomainContent($input, Argument $args, $versionNo, $language): RepositoryValues\Content\Content
Expand Down Expand Up @@ -129,7 +139,7 @@ public function updateDomainContent($input, Argument $args, $versionNo, $languag
return $this->getContentService()->loadContent($contentDraft->id);
}

public function createDomainContent($input, $contentTypeIdentifier, $parentLocationId, $language): RepositoryValues\Content\Content
public function createDomainContent($input, $contentTypeIdentifier, $parentLocationId, $language): Item
{
try {
$contentType = $this->getContentTypeService()->loadContentTypeByIdentifier($contentTypeIdentifier);
Expand Down Expand Up @@ -165,7 +175,7 @@ public function createDomainContent($input, $contentTypeIdentifier, $parentLocat
throw new UserError($e->getMessage(), 0, $e);
}

return $content;
return $this->itemFactory->fromContent($content);
}

public function deleteDomainContent(Argument $args)
Expand Down

0 comments on commit c5b618b

Please sign in to comment.