From e58bfd774f8315b2e5730633f49be6b21d512545 Mon Sep 17 00:00:00 2001 From: Gunnstein Lye <289744+glye@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:09:50 +0200 Subject: [PATCH] IBX-8536: Removed deprecations in graphql (#71) * IBX-8536: Removed deprecations in graphql * Update tests * Some extra cleanup * cs fix --------- Co-authored-by: Dawid Parafinski --- doc/domain_schema.md | 2 +- doc/howto/custom_field_type.md | 15 +-- phpstan-baseline.neon | 95 --------------- .../Resources/config/services/resolvers.yaml | 4 - .../Resources/config/services/schema.yaml | 4 - src/lib/Resolver/DomainContentResolver.php | 8 -- src/lib/Resolver/SearchResolver.php | 9 +- .../ConfigurableFieldDefinitionMapper.php | 2 +- .../FieldDefinitionArgsBuilderMapper.php | 17 --- .../FieldDefinitionInputMapper.php | 18 --- src/lib/Schema/Domain/Content/NameHelper.php | 115 ------------------ src/lib/Schema/ImagesVariationsBuilder.php | 44 ------- 12 files changed, 9 insertions(+), 324 deletions(-) delete mode 100644 src/lib/Schema/Domain/Content/Mapper/FieldDefinition/FieldDefinitionArgsBuilderMapper.php delete mode 100644 src/lib/Schema/Domain/Content/Mapper/FieldDefinition/FieldDefinitionInputMapper.php delete mode 100644 src/lib/Schema/ImagesVariationsBuilder.php diff --git a/doc/domain_schema.md b/doc/domain_schema.md index 1784faa..b8cc26d 100644 --- a/doc/domain_schema.md +++ b/doc/domain_schema.md @@ -104,7 +104,7 @@ Another, `AddDomainContentToDomainGroup`, will add the same Domain Content to it ### Custom Field Types -Fields values are handled by the `AddFieldValueToDomainContent` content domain schema worker. It uses Field Value Builders (instances of `Schema\Domain\Content\FieldValueBuilder\FieldValueBuilder`) to generate the type and resolution for each field. +Fields values are handled by the `AddFieldValueToItem` content domain schema worker. It uses Field Value Builders (instances of `Schema\Domain\Content\FieldValueBuilder\FieldValueBuilder`) to generate the type and resolution for each field. Basic field types are handled by the `BaseFieldValueBuilder`. It maps each fieldtype, using its identifier, to either a type, or a type and a resolver. For the time being, it can not be customized. diff --git a/doc/howto/custom_field_type.md b/doc/howto/custom_field_type.md index b817a63..2c37924 100644 --- a/doc/howto/custom_field_type.md +++ b/doc/howto/custom_field_type.md @@ -124,7 +124,7 @@ class RelationFieldDefinitionMapper extends DecoratingFieldDefinitionMapper impl if (count($settings['selectionContentTypes']) === 1) { $contentType = $this->contentTypeService->loadContentTypeByIdentifier($settings['selectionContentTypes'][0]); - $type = $this->nameHelper->domainContentName($contentType); + $type = $this->nameHelper->itemName($contentType); } else { $type = 'DomainContent'; } @@ -160,15 +160,14 @@ class RelationFieldDefinitionMapper extends DecoratingFieldDefinitionMapper impl } ``` -#### Field Definition Input Mappers -As of v1.0.4, an extra interface is available for mutation input type handling, `FieldDefinitionInputMapper`. -It is used if the input for this field depends on the field definition. For instance, `ezmatrix` -generates its own input types depending on the configured columns. It defines an extra method, `mapToFieldValueInputType`, -that returns a GraphQL type for a Field Definition. +#### Mutation input type handling +If the input for a field depends on the field definition, like `ezmatrix` +which generates its own input types depending on the configured columns, use `mapToFieldValueInputType` +which returns a GraphQL type for a Field Definition. Example: ``` -class MyFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper, FieldDefinitionInputMapper +class MyFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper { public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string { @@ -181,8 +180,6 @@ class MyFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements } ``` -In 2.0, `FieldDefinitionInputMapper` and `FieldDefinitionMapper` will be merged, and the service tag will be deprecated. - ## Resolver expressions Two variables are available in the resolver's expression: diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6d4ed56..ece6d89 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -845,21 +845,6 @@ parameters: count: 1 path: src/lib/Resolver/DomainContentResolver.php - - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\DomainContentResolver\\:\\:resolveDomainFieldValue\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Resolver/DomainContentResolver.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\DomainContentResolver\\:\\:resolveDomainFieldValue\\(\\) has parameter \\$args with no type specified\\.$#" - count: 1 - path: src/lib/Resolver/DomainContentResolver.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\DomainContentResolver\\:\\:resolveDomainFieldValue\\(\\) has parameter \\$fieldDefinitionIdentifier with no type specified\\.$#" - count: 1 - path: src/lib/Resolver/DomainContentResolver.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\DomainContentResolver\\:\\:resolveDomainRelationFieldValue\\(\\) has no return type specified\\.$#" count: 1 @@ -1170,11 +1155,6 @@ parameters: count: 1 path: src/lib/Resolver/SearchResolver.php - - - message: "#^Property Ibexa\\\\GraphQL\\\\Resolver\\\\SearchResolver\\:\\:\\$searchService is never read, only written\\.$#" - count: 1 - path: src/lib/Resolver/SearchResolver.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\SectionResolver\\:\\:resolveSectionById\\(\\) has parameter \\$sectionId with no type specified\\.$#" count: 1 @@ -1600,71 +1580,6 @@ parameters: count: 1 path: src/lib/Schema/Domain/Content/NameHelper.php - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentCollectionField\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentConnection\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentConnection\\(\\) has parameter \\$contentType with no type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentCreateInputName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentField\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentTypeName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainContentUpdateInputName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainGroupField\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainGroupName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainGroupTypesName\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainMutationCreateContentField\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:domainMutationUpdateContentField\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/Domain/Content/NameHelper.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Domain\\\\Content\\\\NameHelper\\:\\:fieldDefinitionField\\(\\) has no return type specified\\.$#" count: 1 @@ -2245,16 +2160,6 @@ parameters: count: 1 path: src/lib/Schema/Generator.php - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\ImagesVariationsBuilder\\:\\:build\\(\\) has no return type specified\\.$#" - count: 1 - path: src/lib/Schema/ImagesVariationsBuilder.php - - - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\ImagesVariationsBuilder\\:\\:build\\(\\) has parameter \\$schema with no value type specified in iterable type array\\.$#" - count: 1 - path: src/lib/Schema/ImagesVariationsBuilder.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Schema\\\\Initializer\\:\\:init\\(\\) has no return type specified\\.$#" count: 1 diff --git a/src/bundle/Resources/config/services/resolvers.yaml b/src/bundle/Resources/config/services/resolvers.yaml index 907c594..e4ba3b5 100644 --- a/src/bundle/Resources/config/services/resolvers.yaml +++ b/src/bundle/Resources/config/services/resolvers.yaml @@ -31,7 +31,6 @@ services: Ibexa\GraphQL\Resolver\DomainContentResolver: tags: - { name: overblog_graphql.resolver, alias: "DomainContentItemsByTypeIdentifier", method: "resolveDomainContentItems" } - - { name: overblog_graphql.resolver, alias: "DomainFieldValue", method: "resolveDomainFieldValue" } - { name: overblog_graphql.resolver, alias: "DomainContentType", method: "resolveDomainContentType" } - { name: overblog_graphql.resolver, alias: "DomainContentItem", method: "resolveDomainContentItem" } - { name: overblog_graphql.resolver, alias: "DomainRelationFieldValue", method: "resolveDomainRelationFieldValue" } @@ -117,9 +116,6 @@ services: tags: - { name: overblog_graphql.resolver, alias: "SearchContent", method: "searchContent" } - { name: overblog_graphql.resolver, alias: "SearchContentOfTypeAsConnection", method: "searchContentOfTypeAsConnection" } - - { name: overblog_graphql.resolver, alias: "SearchLocationsOfTypeAsConnection", method: "searchLocationsOfTypeAsConnection" } - arguments: - $searchService: '@ibexa.siteaccessaware.service.search' Ibexa\GraphQL\Resolver\RichTextResolver: arguments: diff --git a/src/bundle/Resources/config/services/schema.yaml b/src/bundle/Resources/config/services/schema.yaml index b720aff..052cc0b 100644 --- a/src/bundle/Resources/config/services/schema.yaml +++ b/src/bundle/Resources/config/services/schema.yaml @@ -49,8 +49,6 @@ services: arguments: $innerMapper: '@Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\SelectionFieldDefinitionMapper.inner' - Ibexa\GraphQL\Schema\Domain\Content\Worker\FieldDefinition\AddFieldValueToDomainContent: ~ - Ibexa\GraphQL\Schema\Domain\Content\Worker\ContentType\AddItemOfTypeConnectionToGroup: ~ Ibexa\GraphQL\Schema\Domain\Content\Worker\ContentType\AddItemToGroup: ~ @@ -100,8 +98,6 @@ services: Ibexa\GraphQL\Schema\Generator: ~ - Ibexa\GraphQL\Schema\ImagesVariationsBuilder: ~ - Ibexa\GraphQL\Schema\SchemaGenerator: ~ Ibexa\GraphQL\Schema\Domain\Pluralizer: ~ diff --git a/src/lib/Resolver/DomainContentResolver.php b/src/lib/Resolver/DomainContentResolver.php index 13f9126..50dc9a0 100644 --- a/src/lib/Resolver/DomainContentResolver.php +++ b/src/lib/Resolver/DomainContentResolver.php @@ -132,14 +132,6 @@ public function resolveMainUrlAlias(Content $content) return isset($aliases[0]->path) ? $aliases[0]->path : null; } - /** - * @deprecated since v3.0, use ItemResolver::resolveItemFieldValue() instead. - */ - public function resolveDomainFieldValue(Content $content, $fieldDefinitionIdentifier, $args = null) - { - return Field::fromField($content->getField($fieldDefinitionIdentifier, $args['language'] ?? null)); - } - public function resolveDomainRelationFieldValue(?Field $field, $multiple = false) { if ($field === null) { diff --git a/src/lib/Resolver/SearchResolver.php b/src/lib/Resolver/SearchResolver.php index ce7600e..04f2481 100644 --- a/src/lib/Resolver/SearchResolver.php +++ b/src/lib/Resolver/SearchResolver.php @@ -7,7 +7,6 @@ namespace Ibexa\GraphQL\Resolver; -use Ibexa\Contracts\Core\Repository\SearchService; use Ibexa\GraphQL\DataLoader\ContentLoader; use Ibexa\GraphQL\InputMapper\SearchQueryMapper; use Overblog\GraphQLBundle\Relay\Connection\Paginator; @@ -17,11 +16,6 @@ */ class SearchResolver { - /** - * @var \Ibexa\Contracts\Core\Repository\SearchService - */ - private $searchService; - /** * @var \Ibexa\GraphQL\InputMapper\SearchQueryMapper */ @@ -32,10 +26,9 @@ class SearchResolver */ private $contentLoader; - public function __construct(ContentLoader $contentLoader, SearchService $searchService, SearchQueryMapper $queryMapper) + public function __construct(ContentLoader $contentLoader, SearchQueryMapper $queryMapper) { $this->contentLoader = $contentLoader; - $this->searchService = $searchService; $this->queryMapper = $queryMapper; } diff --git a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ConfigurableFieldDefinitionMapper.php b/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ConfigurableFieldDefinitionMapper.php index 1fecb9f..56dc0e2 100644 --- a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ConfigurableFieldDefinitionMapper.php +++ b/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ConfigurableFieldDefinitionMapper.php @@ -11,7 +11,7 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition; use Ibexa\Contracts\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper; -class ConfigurableFieldDefinitionMapper implements FieldDefinitionMapper, FieldDefinitionInputMapper, FieldDefinitionArgsBuilderMapper +class ConfigurableFieldDefinitionMapper implements FieldDefinitionMapper { /** * @var array diff --git a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/FieldDefinitionArgsBuilderMapper.php b/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/FieldDefinitionArgsBuilderMapper.php deleted file mode 100644 index 1630bb2..0000000 --- a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/FieldDefinitionArgsBuilderMapper.php +++ /dev/null @@ -1,17 +0,0 @@ -fieldNameOverrides = $fieldNameOverrides; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemConnectionField() instead. - */ - public function domainContentCollectionField(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemConnectionFieldName() instead.', E_USER_DEPRECATED); - - return $this->itemConnectionField($contentType); - } - public function itemConnectionField(ContentType $contentType) { return $this->pluralize(lcfirst($this->toCamelCase($contentType->identifier))); } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemName() instead. - */ - public function domainContentName(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemName() instead.', E_USER_DEPRECATED); - - return $this->itemName($contentType); - } - public function itemName(ContentType $contentType) { return ucfirst($this->toCamelCase($contentType->identifier)) . 'Item'; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemConnectionName() instead. - */ - public function domainContentConnection($contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemConnectionName() instead.', E_USER_DEPRECATED); - - return $this->itemConnectionName($contentType); - } - public function itemConnectionName($contentType) { return ucfirst($this->toCamelCase($contentType->identifier)) . 'ItemConnection'; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemCreateInputName() instead. - */ - public function domainContentCreateInputName(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemCreateInputName() instead.', E_USER_DEPRECATED); - - return $this->itemCreateInputName($contentType); - } - public function itemCreateInputName(ContentType $contentType) { return ucfirst($this->toCamelCase($contentType->identifier)) . 'ItemCreateInput'; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemUpdateInputName() instead. - */ - public function domainContentUpdateInputName(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemUpdateInputName() instead.', E_USER_DEPRECATED); - - return $this->itemUpdateInputName($contentType); - } - public function itemUpdateInputName(ContentType $contentType) { return ucfirst($this->toCamelCase($contentType->identifier)) . 'ItemUpdateInput'; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemUpdateInputName() instead. - */ - public function domainContentTypeName(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemTypeName() instead.', E_USER_DEPRECATED); - - return $this->itemTypeName($contentType); - } - public function itemTypeName(ContentType $contentType) { return ucfirst($this->toCamelCase($contentType->identifier)) . 'ItemType'; } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemField() instead. - */ - public function domainContentField(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemField() instead.', E_USER_DEPRECATED); - - return $this->itemField($contentType); - } - public function itemField(ContentType $contentType) { return lcfirst($this->toCamelCase($contentType->identifier)); } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemMutationCreateItemField() instead. - */ - public function domainMutationCreateContentField(ContentType $contentType) - { - return $this->itemMutationCreateItemField($contentType); - } - public function itemMutationCreateItemField(ContentType $contentType) { return 'create' . ucfirst($this->itemField($contentType)); } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemMutationUpdateItemField() instead. - */ - public function domainMutationUpdateContentField(ContentType $contentType) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemMutationUpdateItemField() instead.', E_USER_DEPRECATED); - - return $this->itemMutationUpdateItemField($contentType); - } - public function itemMutationUpdateItemField($contentType) { return 'update' . ucfirst($this->itemField($contentType)); } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemGroupName() instead. - */ - public function domainGroupName(ContentTypeGroup $contentTypeGroup) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemGroupName() instead.', E_USER_DEPRECATED); - - return $this->itemGroupName($contentTypeGroup); - } - public function itemGroupName(ContentTypeGroup $contentTypeGroup) { return 'ItemGroup' . ucfirst($this->toCamelCase($this->sanitizeContentTypeGroupIdentifier($contentTypeGroup))); } - /** - * @deprecated since v3.0, will be removed in v4.0. Use itemGroupTypesName() instead. - */ - public function domainGroupTypesName(ContentTypeGroup $contentTypeGroup) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemGroupTypesName() instead.', E_USER_DEPRECATED); - - return $this->itemGroupTypesName($contentTypeGroup); - } - public function itemGroupTypesName(ContentTypeGroup $contentTypeGroup) { return sprintf( @@ -206,13 +98,6 @@ public function itemGroupTypesName(ContentTypeGroup $contentTypeGroup) ); } - public function domainGroupField(ContentTypeGroup $contentTypeGroup) - { - @trigger_error('Deprecated since v3.0, will be removed in v4.0. Use itemGroupField() instead.', E_USER_DEPRECATED); - - return $this->itemGroupField($contentTypeGroup); - } - public function itemGroupField(ContentTypeGroup $contentTypeGroup) { return lcfirst($this->toCamelCase($this->sanitizeContentTypeGroupIdentifier($contentTypeGroup))); diff --git a/src/lib/Schema/ImagesVariationsBuilder.php b/src/lib/Schema/ImagesVariationsBuilder.php deleted file mode 100644 index 7bef853..0000000 --- a/src/lib/Schema/ImagesVariationsBuilder.php +++ /dev/null @@ -1,44 +0,0 @@ -configResolver = $configResolver; - } - - public function build(array &$schema) - { - $schema['ImageVariationIdentifier'] = [ - 'type' => 'enum', - 'config' => [ - 'values' => [], - ], - ]; - - $values = &$schema['ImageVariationIdentifier']['config']['values']; - - foreach (array_keys($this->configResolver->getParameter('image_variations')) as $variationIdentifier) { - $values[$variationIdentifier] = []; - } - } -}