Skip to content

Commit 89a19f5

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into 2.4-develop-sidecar-pr18
2 parents c871e1c + be82efb commit 89a19f5

File tree

42 files changed

+2734
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2734
-337
lines changed

app/code/Magento/BundleGraphQl/etc/graphql/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,11 @@
107107
</argument>
108108
</arguments>
109109
</type>
110+
<type name="Magento\UrlRewriteGraphQl\Model\RoutableInterfaceTypeResolver">
111+
<arguments>
112+
<argument name="productTypeNameResolvers" xsi:type="array">
113+
<item name="bundle_product_type_resolver" xsi:type="object">Magento\BundleGraphQl\Model\BundleProductTypeResolver</item>
114+
</argument>
115+
</arguments>
116+
</type>
110117
</config>

app/code/Magento/BundleGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type BundleItemOption @doc(description: "BundleItemOption defines characteristic
7272
uid: ID! @doc(description: "The unique ID for a `BundleItemOption` object.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\BundleItemOptionUid")
7373
}
7474

75-
type BundleProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "BundleProduct defines basic features of a bundle product and contains multiple BundleItems.") {
75+
type BundleProduct implements ProductInterface, RoutableInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "Defines basic features of a bundle product and contains multiple BundleItems") {
7676
price_view: PriceViewEnum @doc(description: "One of PRICE_RANGE or AS_LOW_AS.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\PriceView")
7777
dynamic_price: Boolean @doc(description: "Indicates whether the bundle product has a dynamic price.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\DynamicPrice")
7878
dynamic_sku: Boolean @doc(description: "Indicates whether the bundle product has a dynamic SK.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\DynamicSku")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
12+
/**
13+
* @inheritdoc
14+
*/
15+
class CategoryTypeResolver implements TypeResolverInterface
16+
{
17+
const CATEGORY = 'CATEGORY';
18+
const TYPE_RESOLVER = 'CategoryTree';
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function resolveType(array $data) : string
24+
{
25+
if (isset($data['type_id']) && $data['type_id'] == self::CATEGORY) {
26+
return self::TYPE_RESOLVER;
27+
}
28+
return '';
29+
}
30+
}

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type CustomizableAreaValue @doc(description: "CustomizableAreaValue defines the
142142
uid: ID! @doc(description: "The unique ID for a `CustomizableAreaValue` object.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CustomizableEnteredOptionValueUid")
143143
}
144144

145-
type CategoryTree implements CategoryInterface @doc(description: "Category Tree implementation.") {
145+
type CategoryTree implements CategoryInterface, RoutableInterface @doc(description: "Category tree implementation") {
146146
children: [CategoryTree] @doc(description: "Child categories tree.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree")
147147
}
148148

@@ -308,10 +308,10 @@ type CustomizableCheckboxValue @doc(description: "CustomizableCheckboxValue defi
308308
uid: ID! @doc(description: "The unique ID for a `CustomizableCheckboxValue` object.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CustomizableSelectedOptionValueUid")
309309
}
310310

311-
type VirtualProduct implements ProductInterface, CustomizableProductInterface @doc(description: "A virtual product is non-tangible product that does not require shipping and is not kept in inventory.") {
311+
type VirtualProduct implements ProductInterface, RoutableInterface, CustomizableProductInterface @doc(description: "A virtual product is a non-tangible product that does not require shipping and is not kept in inventory") {
312312
}
313313

314-
type SimpleProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "A simple product is tangible and are usually sold as single units or in fixed quantities.")
314+
type SimpleProduct implements ProductInterface, RoutableInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "A simple product is tangible and is usually sold in single units or in fixed quantities")
315315
{
316316
}
317317

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite;
9+
10+
use Magento\Catalog\Model\CategoryRepository;
11+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree as CategoryTreeDataProvider;
12+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ExtractDataFromCategoryTree;
13+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderInterface;
16+
17+
class CatalogTreeDataProvider implements EntityDataProviderInterface
18+
{
19+
/**
20+
* @var ExtractDataFromCategoryTree
21+
*/
22+
private $extractDataFromCategoryTree;
23+
24+
/**
25+
* @var CategoryTreeDataProvider
26+
*/
27+
private $categoryTree;
28+
29+
/**
30+
* @var CategoryRepository
31+
*/
32+
private $categoryRepository;
33+
34+
/**
35+
* @param CategoryTreeDataProvider $categoryTree
36+
* @param ExtractDataFromCategoryTree $extractDataFromCategoryTree
37+
* @param CategoryRepository $categoryRepository
38+
*/
39+
public function __construct(
40+
CategoryTreeDataProvider $categoryTree,
41+
ExtractDataFromCategoryTree $extractDataFromCategoryTree,
42+
CategoryRepository $categoryRepository
43+
) {
44+
$this->categoryTree = $categoryTree;
45+
$this->extractDataFromCategoryTree = $extractDataFromCategoryTree;
46+
$this->categoryRepository = $categoryRepository;
47+
}
48+
49+
/**
50+
* Get catalog tree data
51+
*
52+
* @param string $entity_type
53+
* @param int $id
54+
* @param ResolveInfo|null $info
55+
* @return array
56+
* @throws GraphQlNoSuchEntityException
57+
*/
58+
public function getData(
59+
string $entity_type,
60+
int $id,
61+
ResolveInfo $info = null
62+
): array {
63+
$categoryId = (int)$id;
64+
$categoriesTree = $this->categoryTree->getTree($info, $categoryId);
65+
if (empty($categoriesTree) || ($categoriesTree->count() == 0)) {
66+
throw new GraphQlNoSuchEntityException(__('Category doesn\'t exist'));
67+
}
68+
$result = current($this->extractDataFromCategoryTree->execute($categoriesTree));
69+
$result['type_id'] = $entity_type;
70+
return $result;
71+
}
72+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite;
9+
10+
use Magento\Catalog\Model\ProductRepository;
11+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
12+
use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderInterface;
13+
14+
class ProductDataProvider implements EntityDataProviderInterface
15+
{
16+
/**
17+
* @var ProductRepository
18+
*/
19+
private $productRepository;
20+
21+
/**
22+
* @param ProductRepository $productRepository
23+
*/
24+
public function __construct(
25+
ProductRepository $productRepository
26+
) {
27+
$this->productRepository = $productRepository;
28+
}
29+
30+
/**
31+
* Get product data
32+
*
33+
* @param string $entity_type
34+
* @param int $id
35+
* @param ResolveInfo|null $info
36+
* @return array
37+
* @throws \Magento\Framework\Exception\NoSuchEntityException
38+
*/
39+
public function getData(string $entity_type, int $id, ResolveInfo $info = null): array
40+
{
41+
$product = $this->productRepository->getById($id);
42+
$result = $product->getData();
43+
$result['model'] = $product;
44+
return $result;
45+
}
46+
}

app/code/Magento/CatalogUrlRewriteGraphQl/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"php": "~7.3.0||~7.4.0",
77
"magento/module-store": "*",
88
"magento/module-catalog": "*",
9+
"magento/module-catalog-graph-ql": "*",
10+
"magento/module-url-rewrite-graph-ql": "*",
911
"magento/framework": "*"
1012
},
1113
"suggest": {

app/code/Magento/CatalogUrlRewriteGraphQl/etc/di.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@
3030
</argument>
3131
</arguments>
3232
</type>
33+
34+
<type name="Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderComposite">
35+
<arguments>
36+
<argument name="dataProviders" xsi:type="array">
37+
<item name="category" xsi:type="object">Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\CatalogTreeDataProvider</item>
38+
<item name="product" xsi:type="object">Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\ProductDataProvider</item>
39+
</argument>
40+
</arguments>
41+
</type>
3342
</config>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\UrlRewriteGraphQl\Model\RoutableInterfaceTypeResolver">
10+
<arguments>
11+
<argument name="productTypeNameResolvers" xsi:type="array">
12+
<item name="category_type_resolver" xsi:type="object">Magento\CatalogGraphQl\Model\CategoryTypeResolver</item>
13+
<item name="catalog_type_resolver" xsi:type="object">Magento\CatalogGraphQl\Model\CatalogProductTypeResolver</item>
14+
</argument>
15+
</arguments>
16+
</type>
17+
</config>

app/code/Magento/CmsGraphQl/etc/schema.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Query {
2020
): CmsBlocks @resolver(class: "Magento\\CmsGraphQl\\Model\\Resolver\\Blocks") @doc(description: "The CMS block query returns information about CMS blocks") @cache(cacheIdentity: "Magento\\CmsGraphQl\\Model\\Resolver\\Block\\Identity")
2121
}
2222

23-
type CmsPage @doc(description: "CMS page defines all CMS page information") {
23+
type CmsPage implements RoutableInterface @doc(description: "CMS page defines all CMS page information") {
2424
identifier: String @doc(description: "Identifier of the CMS page")
2525
url_key: String @doc(description: "URL key of CMS page")
2626
title: String @doc(description: "CMS page title")
@@ -40,4 +40,4 @@ type CmsBlock @doc(description: "CMS block defines all CMS block information") {
4040
identifier: String @doc(description: "CMS block identifier")
4141
title: String @doc(description: "CMS block title")
4242
content: String @doc(description: "CMS block content")
43-
}
43+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CmsUrlRewriteGraphQl\Model;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
12+
/**
13+
* @inheritdoc
14+
*/
15+
class CmsPageTypeResolver implements TypeResolverInterface
16+
{
17+
const CMS_PAGE = 'CMS_PAGE';
18+
const TYPE_RESOLVER = 'CmsPage';
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function resolveType(array $data) : string
24+
{
25+
if (isset($data['type_id']) && $data['type_id'] == self::CMS_PAGE) {
26+
return self::TYPE_RESOLVER;
27+
}
28+
return '';
29+
}
30+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CmsUrlRewriteGraphQl\Model\DataProvider\UrlRewrite;
9+
10+
use Magento\CmsGraphQl\Model\Resolver\DataProvider\Page as PageDataProvider;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13+
use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderInterface;
14+
15+
class Page implements EntityDataProviderInterface
16+
{
17+
/**
18+
* @var PageDataProvider
19+
*/
20+
private $pageDataProvider;
21+
22+
/**
23+
* Route constructor.
24+
* @param PageDataProvider $pageDataProvider
25+
*/
26+
public function __construct(
27+
PageDataProvider $pageDataProvider
28+
) {
29+
$this->pageDataProvider = $pageDataProvider;
30+
}
31+
32+
/**
33+
* Get Page data
34+
*
35+
* @param string $entity_type
36+
* @param int $id
37+
* @param ResolveInfo|null $info
38+
* @return array
39+
* @throws NoSuchEntityException
40+
*/
41+
public function getData(string $entity_type, int $id, ResolveInfo $info = null): array
42+
{
43+
$result = $this->pageDataProvider->getDataByPageId((int)$id);
44+
$result['type_id'] = $entity_type;
45+
return $result;
46+
}
47+
}

app/code/Magento/CmsUrlRewriteGraphQl/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"magento/framework": "*",
88
"magento/module-cms": "*",
99
"magento/module-store": "*",
10-
"magento/module-url-rewrite-graph-ql": "*"
10+
"magento/module-url-rewrite-graph-ql": "*",
11+
"magento/module-cms-graph-ql": "*"
1112
},
1213
"suggest": {
1314
"magento/module-cms-url-rewrite": "*",

app/code/Magento/CmsUrlRewriteGraphQl/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@
2020
</argument>
2121
</arguments>
2222
</type>
23+
<type name="Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderComposite">
24+
<arguments>
25+
<argument name="dataProviders" xsi:type="array">
26+
<item name="cms_page" xsi:type="object">Magento\CmsUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\Page</item>
27+
</argument>
28+
</arguments>
29+
</type>
2330
</config>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\UrlRewriteGraphQl\Model\RoutableInterfaceTypeResolver">
10+
<arguments>
11+
<argument name="productTypeNameResolvers" xsi:type="array">
12+
<item name="cms_page_type_resolver" xsi:type="object">Magento\CmsUrlRewriteGraphQl\Model\CmsPageTypeResolver</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>

app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@
6060
</arguments>
6161
</type>
6262

63+
<type name="Magento\UrlRewriteGraphQl\Model\RoutableInterfaceTypeResolver">
64+
<arguments>
65+
<argument name="productTypeNameResolvers" xsi:type="array">
66+
<item name="configurable_product_type_resolver" xsi:type="object">Magento\ConfigurableProductGraphQl\Model\ConfigurableProductTypeResolver</item>
67+
</argument>
68+
</arguments>
69+
</type>
6370
<type name="Magento\ConfigurableProduct\Model\Product\Configuration\Item\ItemProductResolver">
6471
<plugin name="configured_variant" type="Magento\ConfigurableProductGraphQl\Plugin\Product\Configuration\Item\ItemResolver"/>
6572
</type>

app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type Mutation {
44
addConfigurableProductsToCart(input: AddConfigurableProductsToCartInput): AddConfigurableProductsToCartOutput @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\AddConfigurableProductsToCart")
55
}
66

7-
type ConfigurableProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "ConfigurableProduct defines basic features of a configurable product and its simple product variants") {
7+
type ConfigurableProduct implements ProductInterface, RoutableInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "ConfigurableProduct defines basic features of a configurable product and its simple product variants") {
88
variants: [ConfigurableVariant] @doc(description: "An array of variants of products") @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\ConfigurableVariant")
99
configurable_options: [ConfigurableProductOptions] @doc(description: "An array of linked simple product items") @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\Options")
1010
configurable_product_options_selection(configurableOptionValueUids: [ID!]): ConfigurableProductOptionsSelection @doc(description: "Specified configurable product options selection") @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\OptionsSelectionMetadata")

0 commit comments

Comments
 (0)