Skip to content

Commit

Permalink
IBX-8536: Removed deprecations in graphql (#71)
Browse files Browse the repository at this point in the history
* IBX-8536: Removed deprecations in graphql

* Update tests

* Some extra cleanup

* cs fix

---------

Co-authored-by: Dawid Parafinski <[email protected]>
  • Loading branch information
glye and ViniTou authored Oct 23, 2024
1 parent 564ea4e commit e58bfd7
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 324 deletions.
2 changes: 1 addition & 1 deletion doc/domain_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 6 additions & 9 deletions doc/howto/custom_field_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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
{
Expand All @@ -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:

Expand Down
95 changes: 0 additions & 95 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/bundle/Resources/config/services/resolvers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions src/bundle/Resources/config/services/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ~
Expand Down Expand Up @@ -100,8 +98,6 @@ services:

Ibexa\GraphQL\Schema\Generator: ~

Ibexa\GraphQL\Schema\ImagesVariationsBuilder: ~

Ibexa\GraphQL\Schema\SchemaGenerator: ~

Ibexa\GraphQL\Schema\Domain\Pluralizer: ~
Expand Down
8 changes: 0 additions & 8 deletions src/lib/Resolver/DomainContentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 1 addition & 8 deletions src/lib/Resolver/SearchResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,11 +16,6 @@
*/
class SearchResolver
{
/**
* @var \Ibexa\Contracts\Core\Repository\SearchService
*/
private $searchService;

/**
* @var \Ibexa\GraphQL\InputMapper\SearchQueryMapper
*/
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e58bfd7

Please sign in to comment.