Skip to content

Commit a4b64dd

Browse files
author
Mateusz Dębiński
committed
Changed parameter name, made $args nullable
1 parent b02ba5c commit a4b64dd

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/bundle/Resources/config/default_settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
22
ibexa.graphql.schema.should.extend.ezurl: false
3-
ibexa.graphql.schema.ezobjectrelationlist.enable_pagination: false
3+
ibexa.graphql.schema.ibexa_object_relation_list.enable_pagination: false
44
ibexa.graphql.schema.content.field_name.override:
55
id: id_
66
ibexa.graphql.schema.content.mapping.field_definition_type:

src/bundle/Resources/config/services/schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ services:
4343
arguments:
4444
$contentTypeService: '@ibexa.siteaccessaware.service.content_type'
4545
$innerMapper: '@Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\RelationFieldDefinitionMapper.inner'
46-
$enablePagination: '%ibexa.graphql.schema.ezobjectrelationlist.enable_pagination%'
46+
$enablePagination: '%ibexa.graphql.schema.ibexa_object_relation_list.enable_pagination%'
4747

4848
Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\SelectionFieldDefinitionMapper:
4949
decorates: Ibexa\Contracts\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper

src/lib/Resolver/RelationFieldResolver.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Ibexa\GraphQL\Resolver;
88

99
use GraphQL\Error\UserError;
10+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
1011
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
1112
use Ibexa\Core\FieldType;
1213
use Ibexa\GraphQL\DataLoader\ContentLoader;
@@ -36,7 +37,7 @@ public function __construct(
3637
$this->enablePagination = $enablePagination;
3738
}
3839

39-
public function resolveRelationFieldValue(Field $field, $multiple = false, Argument $args)
40+
public function resolveRelationFieldValue(Field $field, $multiple = false, ?Argument $args = null)
4041
{
4142
$destinationContentIds = $this->getContentIds($field);
4243

@@ -49,13 +50,13 @@ public function resolveRelationFieldValue(Field $field, $multiple = false, Argum
4950
);
5051

5152
if ($multiple) {
52-
if (!$this->enablePagination) {
53+
if (!$this->enablePagination || $args === null) {
5354
$contentItems = $this->contentLoader->find($query);
5455

5556
return array_map(
56-
function ($contentId) use ($contentItems) {
57+
function (int $contentId) use ($contentItems) {
5758
return $this->itemFactory->fromContent(
58-
$contentItems[array_search($contentId, array_column($contentItems, 'id'))]
59+
$contentItems[array_search($contentId, array_column($contentItems, 'id'), true)]
5960
);
6061
},
6162
$destinationContentIds
@@ -68,7 +69,7 @@ function ($contentId) use ($contentItems) {
6869
$contentItems = $this->contentLoader->find($query);
6970

7071
return array_map(
71-
function ($content) {
72+
function (Content $content) {
7273
return $this->itemFactory->fromContent(
7374
$content
7475
);
@@ -103,11 +104,13 @@ private function getContentIds(Field $field): array
103104
{
104105
if ($field->value instanceof FieldType\RelationList\Value) {
105106
return $field->value->destinationContentIds;
106-
} elseif ($field->value instanceof FieldType\Relation\Value) {
107+
}
108+
109+
if ($field->value instanceof FieldType\Relation\Value) {
107110
return [$field->value->destinationContentId];
108-
} else {
109-
throw new UserError('\$field does not contain a RelationList or Relation Field value');
110111
}
112+
113+
throw new UserError('\$field does not contain a RelationList or Relation Field value');
111114
}
112115
}
113116

src/lib/Schema/Domain/Content/Mapper/FieldDefinition/RelationFieldDefinitionMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function mapToFieldValueType(FieldDefinition $fieldDefinition): ?string
5858
@trigger_error(
5959
'Disable pagination for ezobjectrelationlist has been deprecated since version 4.6 ' .
6060
'and will be removed in version 5.0. To start receiving `RelationsConnection` instead of the deprecated ' .
61-
'`[' . $type . ']`, set the parameter `ibexa.graphql.schema.ezobjectrelationlist.enable_pagination` to `true`.',
61+
'`[' . $type . ']`, set the parameter `ibexa.graphql.schema.ibexa_object_relation_list.enable_pagination` to `true`.',
6262
E_USER_DEPRECATED
6363
);
6464

0 commit comments

Comments
 (0)