From f616e1fa4254efd4f660d241e3391344cd61c5a8 Mon Sep 17 00:00:00 2001 From: matx132 Date: Mon, 5 Feb 2024 16:04:25 +0100 Subject: [PATCH 1/6] IBX-7603: Added missing subfield for ezurl --- src/Resources/config/default_settings.yaml | 1 + src/Resources/config/graphql/Field.types.yaml | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Resources/config/default_settings.yaml b/src/Resources/config/default_settings.yaml index cc01bbe..30d9136 100644 --- a/src/Resources/config/default_settings.yaml +++ b/src/Resources/config/default_settings.yaml @@ -81,4 +81,5 @@ parameters: definition_type: TextBlockFieldDefinition value_type: String ezurl: + value_type: UrlFieldValue input_type: UrlFieldInput diff --git a/src/Resources/config/graphql/Field.types.yaml b/src/Resources/config/graphql/Field.types.yaml index 39b96d3..f413872 100644 --- a/src/Resources/config/graphql/Field.types.yaml +++ b/src/Resources/config/graphql/Field.types.yaml @@ -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" From b278248ccc6b62e0c8de3a30fdf9853b929eb756 Mon Sep 17 00:00:00 2001 From: matx132 Date: Mon, 1 Jul 2024 15:40:24 +0200 Subject: [PATCH 2/6] IBX-7603: A new flag has been introduced that generates a different schema for ezurl --- composer.json | 2 +- src/Resources/config/default_settings.yaml | 2 +- .../config/graphql/FieldValueInput.types.yaml | 4 +- src/Resources/config/services/schema.yaml | 6 ++ .../UrlFieldDefinitionMapper.php | 63 +++++++++++++++++++ 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php diff --git a/composer.json b/composer.json index 5e44c2c..9330feb 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "bdunogier/ezplatform-graphql-bundle": "self.version" }, "require": { - "php": "^7.3 || ^8.0", + "php": "^7.4 || ^8.0", "ext-dom": "*", "ezsystems/ezplatform-kernel": "^1.3@dev", "ezsystems/ezplatform-admin-ui": "^2.0@dev", diff --git a/src/Resources/config/default_settings.yaml b/src/Resources/config/default_settings.yaml index 30d9136..7e0ddd7 100644 --- a/src/Resources/config/default_settings.yaml +++ b/src/Resources/config/default_settings.yaml @@ -1,4 +1,5 @@ parameters: + ibexa.graphql.schema.should.extend.ezurl: true ezplatform_graphql.schema.content.field_name.override: id: id_ ezplatform_graphql.schema.content.mapping.field_definition_type: @@ -81,5 +82,4 @@ parameters: definition_type: TextBlockFieldDefinition value_type: String ezurl: - value_type: UrlFieldValue input_type: UrlFieldInput diff --git a/src/Resources/config/graphql/FieldValueInput.types.yaml b/src/Resources/config/graphql/FieldValueInput.types.yaml index 91c3c9c..d2c287f 100644 --- a/src/Resources/config/graphql/FieldValueInput.types.yaml +++ b/src/Resources/config/graphql/FieldValueInput.types.yaml @@ -26,10 +26,10 @@ UrlFieldInput: config: fields: link: - type: String! + type: String description: "The link's URL" text: - type: String + type: String! description: "The link's name or description" MapLocationFieldInput: diff --git a/src/Resources/config/services/schema.yaml b/src/Resources/config/services/schema.yaml index fb4eacf..9ff899e 100644 --- a/src/Resources/config/services/schema.yaml +++ b/src/Resources/config/services/schema.yaml @@ -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: ~ diff --git a/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php new file mode 100644 index 0000000..3730c90 --- /dev/null +++ b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php @@ -0,0 +1,63 @@ +innerMapper = $innerMapper; + $this->shouldExtendUrlInputType = $shouldExtendUrlInputType; + } + + public function mapToFieldDefinitionType(FieldDefinition $fieldDefinition): string + { + return $this->innerMapper->mapToFieldDefinitionType($fieldDefinition); + } + + public function mapToFieldValueType(FieldDefinition $fieldDefinition): string + { + $type = $this->innerMapper->mapToFieldValueType($fieldDefinition); + if ($fieldDefinition->fieldTypeIdentifier === self::FIELD_TYPE_IDENTIFIER) { + 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; + } + + public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): string + { + return $this->innerMapper->mapToFieldValueResolver($fieldDefinition); + } + + public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string + { + return $this->innerMapper->mapToFieldValueInputType($contentType, $fieldDefinition); + } + + public function mapToFieldValueArgsBuilder(FieldDefinition $fieldDefinition): ?string + { + return $this->innerMapper->mapToFieldValueArgsBuilder($fieldDefinition); + } +} From f0db3d68a64fcdc8270d432ff7fba7b88b81228b Mon Sep 17 00:00:00 2001 From: matx132 Date: Mon, 15 Jul 2024 15:23:26 +0200 Subject: [PATCH 3/6] Used DecoratingFieldDefinitionMapper for UrlFieldDefinitionMapper, removed php 7.3 from github ci --- .github/workflows/ci.yaml | 1 - .../UrlFieldDefinitionMapper.php | 58 ++++++++----------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3c99fd..1e8ff85 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,7 +42,6 @@ jobs: fail-fast: false matrix: php: - - '7.3' - '7.4' - '8.0' composer_options: [ "" ] diff --git a/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php index 3730c90..1baaae3 100644 --- a/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php +++ b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php @@ -6,58 +6,46 @@ */ 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\ContentType; use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; -class UrlFieldDefinitionMapper implements FieldDefinitionMapper +class UrlFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper { private const FIELD_TYPE_IDENTIFIER = 'ezurl'; - private FieldDefinitionMapper $innerMapper; private bool $shouldExtendUrlInputType; - public function __construct(FieldDefinitionMapper $innerMapper, bool $shouldExtendUrlInputType) - { - $this->innerMapper = $innerMapper; + public function __construct( + FieldDefinitionMapper $innerMapper, + bool $shouldExtendUrlInputType + ) { + parent::__construct($innerMapper); $this->shouldExtendUrlInputType = $shouldExtendUrlInputType; } - public function mapToFieldDefinitionType(FieldDefinition $fieldDefinition): string - { - return $this->innerMapper->mapToFieldDefinitionType($fieldDefinition); - } - public function mapToFieldValueType(FieldDefinition $fieldDefinition): string { - $type = $this->innerMapper->mapToFieldValueType($fieldDefinition); - if ($fieldDefinition->fieldTypeIdentifier === self::FIELD_TYPE_IDENTIFIER) { - 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 - ); - } + $type = parent::mapToFieldValueType($fieldDefinition); + if (!$this->canMap($fieldDefinition)) { + return $type; } - return $type; - } - - public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): string - { - return $this->innerMapper->mapToFieldValueResolver($fieldDefinition); - } + 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 + ); + } - public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string - { - return $this->innerMapper->mapToFieldValueInputType($contentType, $fieldDefinition); + return $type; } - public function mapToFieldValueArgsBuilder(FieldDefinition $fieldDefinition): ?string + protected function getFieldTypeIdentifier(): string { - return $this->innerMapper->mapToFieldValueArgsBuilder($fieldDefinition); + return self::FIELD_TYPE_IDENTIFIER; } } From 98faf30ee7e892ca5e1ef932146b36678828cc94 Mon Sep 17 00:00:00 2001 From: matx132 Date: Tue, 16 Jul 2024 10:30:44 +0200 Subject: [PATCH 4/6] Restored support PHP 7.3 --- .github/workflows/ci.yaml | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1e8ff85..b3c99fd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,6 +42,7 @@ jobs: fail-fast: false matrix: php: + - '7.3' - '7.4' - '8.0' composer_options: [ "" ] diff --git a/composer.json b/composer.json index 9330feb..5e44c2c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "bdunogier/ezplatform-graphql-bundle": "self.version" }, "require": { - "php": "^7.4 || ^8.0", + "php": "^7.3 || ^8.0", "ext-dom": "*", "ezsystems/ezplatform-kernel": "^1.3@dev", "ezsystems/ezplatform-admin-ui": "^2.0@dev", From d41943d9e454803b7817ac09aa12920c35bb7b83 Mon Sep 17 00:00:00 2001 From: matx132 Date: Tue, 16 Jul 2024 10:41:06 +0200 Subject: [PATCH 5/6] Corrected code for PHP 7.3, changed parameter to default false --- src/Resources/config/default_settings.yaml | 2 +- .../Mapper/FieldDefinition/UrlFieldDefinitionMapper.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Resources/config/default_settings.yaml b/src/Resources/config/default_settings.yaml index 7e0ddd7..9e00cde 100644 --- a/src/Resources/config/default_settings.yaml +++ b/src/Resources/config/default_settings.yaml @@ -1,5 +1,5 @@ parameters: - ibexa.graphql.schema.should.extend.ezurl: true + ibexa.graphql.schema.should.extend.ezurl: false ezplatform_graphql.schema.content.field_name.override: id: id_ ezplatform_graphql.schema.content.mapping.field_definition_type: diff --git a/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php index 1baaae3..f583bc6 100644 --- a/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php +++ b/src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php @@ -13,7 +13,9 @@ class UrlFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper { private const FIELD_TYPE_IDENTIFIER = 'ezurl'; - private bool $shouldExtendUrlInputType; + + /** @var bool */ + private $shouldExtendUrlInputType; public function __construct( FieldDefinitionMapper $innerMapper, From b203ffebb1055506492debd809b4f2d6901f93d5 Mon Sep 17 00:00:00 2001 From: matx132 Date: Tue, 16 Jul 2024 12:16:44 +0200 Subject: [PATCH 6/6] Restored UrlFieldInput --- src/Resources/config/graphql/FieldValueInput.types.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/config/graphql/FieldValueInput.types.yaml b/src/Resources/config/graphql/FieldValueInput.types.yaml index d2c287f..91c3c9c 100644 --- a/src/Resources/config/graphql/FieldValueInput.types.yaml +++ b/src/Resources/config/graphql/FieldValueInput.types.yaml @@ -26,10 +26,10 @@ UrlFieldInput: config: fields: link: - type: String + type: String! description: "The link's URL" text: - type: String! + type: String description: "The link's name or description" MapLocationFieldInput: