Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7603: Added missing subfield for ezurl #137

Open
wants to merge 6 commits into
base: 2.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
ibexa.graphql.schema.should.extend.ezurl: false
ezplatform_graphql.schema.content.field_name.override:
id: id_
ezplatform_graphql.schema.content.mapping.field_definition_type:
Expand Down
13 changes: 13 additions & 0 deletions src/Resources/config/graphql/Field.types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,16 @@ SelectionFieldValue:
type: "String"
description: "String representation of the value"
resolve: "@=value"

UrlFieldValue:
type: object
config:
fields:
link:
type: String
description: "The link's URL"
resolve: "@=value.link"
text:
type: String
description: "The link's name or description"
resolve: "@=value.text"
6 changes: 6 additions & 0 deletions src/Resources/config/services/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ services:
arguments:
$innerMapper: '@EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\SelectionFieldDefinitionMapper.inner'

Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\UrlFieldDefinitionMapper:
decorates: EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper
arguments:
$innerMapper: '@Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\UrlFieldDefinitionMapper.inner'
$shouldExtendUrlInputType: '%ibexa.graphql.schema.should.extend.ezurl%'

EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Worker\ContentType\AddContentOfTypeConnectionToDomainGroup: ~

EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Worker\ContentType\AddContentTypeToContentTypeIdentifierList: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition;

use EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper;
use EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper;
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;

class UrlFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper
{
private const FIELD_TYPE_IDENTIFIER = 'ezurl';

/** @var bool */
private $shouldExtendUrlInputType;

public function __construct(
FieldDefinitionMapper $innerMapper,
bool $shouldExtendUrlInputType
) {
parent::__construct($innerMapper);
$this->shouldExtendUrlInputType = $shouldExtendUrlInputType;
}

public function mapToFieldValueType(FieldDefinition $fieldDefinition): string
{
$type = parent::mapToFieldValueType($fieldDefinition);
if (!$this->canMap($fieldDefinition)) {
return $type;
}

if ($this->shouldExtendUrlInputType) {
$type = 'UrlFieldValue';
} else {
@trigger_error(
'The return type `string` for the URL field has been deprecated since version 3.3 ' .
'and will be removed in version 5.0. To start receiving `UrlFieldInput` instead of the deprecated ' .
'`string`, set the parameter `ibexa.graphql.schema.should.extend.ezurl` to `true`.',
E_USER_DEPRECATED
);
}

return $type;
}

protected function getFieldTypeIdentifier(): string
{
return self::FIELD_TYPE_IDENTIFIER;
}
}
Loading