diff --git a/composer.json b/composer.json index 6d6785a..b86d99a 100644 --- a/composer.json +++ b/composer.json @@ -41,8 +41,7 @@ "ibexa/http-cache": "~4.5.0@dev", "overblog/graphiql-bundle": "^0.2", "phpspec/phpspec": "^7.1", - "friendsofphp/php-cs-fixer": "^3.0", - "ibexa/code-style": "^1.0", + "ibexa/code-style": "~1.2.0", "mikey179/vfsstream": "^1.6" }, "autoload": { diff --git a/src/bundle/Resources/config/graphql/ContentType.types.yaml b/src/bundle/Resources/config/graphql/ContentType.types.yaml index 78d73d4..fd7803c 100644 --- a/src/bundle/Resources/config/graphql/ContentType.types.yaml +++ b/src/bundle/Resources/config/graphql/ContentType.types.yaml @@ -107,7 +107,7 @@ ContentTypeGroup: resolve: "@=resolver('UserById', [value.modifierId])" contentTypes: type: "[ContentType]" - resolve: "@=resolver('ContentTypesFromGroup', {'groupId': value.id})" + resolve: "@=query('ContentTypesFromGroup', {'groupId': value.id})" groups: type: "[ContentTypeGroup]" diff --git a/src/bundle/Resources/config/graphql/DomainContent.types.yaml b/src/bundle/Resources/config/graphql/DomainContent.types.yaml index 21bfdae..e6fd159 100644 --- a/src/bundle/Resources/config/graphql/DomainContent.types.yaml +++ b/src/bundle/Resources/config/graphql/DomainContent.types.yaml @@ -72,7 +72,7 @@ AbstractDomainContent: resolve: "@=resolver('MainUrlAlias', [value])" _thumbnail: type: Thumbnail - resolve: "@=resolver('ContentThumbnail', [value])" + resolve: "@=query('Thumbnail', value.getThumbnail())" UntypedContent: type: object diff --git a/src/bundle/Resources/config/graphql/Item.types.yaml b/src/bundle/Resources/config/graphql/Item.types.yaml index 57d8510..aee4c5c 100644 --- a/src/bundle/Resources/config/graphql/Item.types.yaml +++ b/src/bundle/Resources/config/graphql/Item.types.yaml @@ -60,7 +60,7 @@ AbstractItem: resolve: "@=resolver('ItemUrlAlias', [value])" _thumbnail: type: Thumbnail - resolve: "@=resolver('ContentThumbnail', [value.getContent()])" + resolve: "@=query('Thumbnail', value.getContent().getThumbnail())" UntypedItem: type: object diff --git a/src/bundle/Resources/config/graphql/User.types.yaml b/src/bundle/Resources/config/graphql/User.types.yaml index 423a279..824d41c 100644 --- a/src/bundle/Resources/config/graphql/User.types.yaml +++ b/src/bundle/Resources/config/graphql/User.types.yaml @@ -11,7 +11,7 @@ User: resolve: "@=value.contentInfo.name" content: type: "UserItem" - resolve: "@=value" + resolve: "@=query('Item', {id: value.id})" version: type: "Version" description: "Current version metadata" @@ -23,6 +23,9 @@ User: groups: type: "[UserGroup]" resolve: "@=resolver('UserGroupsByUserId', [value.id])" + thumbnail: + type: Thumbnail + resolve: "@=query('Thumbnail', value.getThumbnail())" UserGroup: type: object @@ -35,9 +38,9 @@ UserGroup: type: "String" resolve: "@=value.contentInfo.name" content: - description: "The User content item" + description: "The User Group content item" type: "UserGroupItem" - resolve: "@=value" + resolve: "@=query('Item', {id: value.id})" version: type: "Version" description: "Current version" diff --git a/src/bundle/Resources/config/services/resolvers.yaml b/src/bundle/Resources/config/services/resolvers.yaml index acf710d..8b55469 100644 --- a/src/bundle/Resources/config/services/resolvers.yaml +++ b/src/bundle/Resources/config/services/resolvers.yaml @@ -58,6 +58,10 @@ services: arguments: $thumbnailStrategy: '@Ibexa\Core\Repository\Strategy\ContentThumbnail\ThumbnailChainStrategy' + Ibexa\GraphQL\Resolver\ThumbnailResolver: + tags: + - { name: overblog_graphql.resolver, alias: "Thumbnail", method: "resolveThumbnail" } + Ibexa\GraphQL\Mutation\Authentication: arguments: $authenticator: '@?ibexa.rest.session_authenticator' diff --git a/src/lib/Resolver/ThumbnailResolver.php b/src/lib/Resolver/ThumbnailResolver.php new file mode 100644 index 0000000..3a00d8e --- /dev/null +++ b/src/lib/Resolver/ThumbnailResolver.php @@ -0,0 +1,32 @@ + $thumbnail->resource, + 'width' => $thumbnail->width, + 'height' => $thumbnail->height, + 'mimeType' => $thumbnail->mimeType, + 'alternativeText' => '', + ]; + } +}