Skip to content

Commit 7fd2c34

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-37193
2 parents 85e5501 + 05fce8b commit 7fd2c34

File tree

35 files changed

+603
-68
lines changed

35 files changed

+603
-68
lines changed

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,18 @@ define([
219219
_.each(tmpData, function (row, index) {
220220
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + index);
221221
row.attributes = $('<i></i>').text(row.attributes).html();
222-
row.sku = row.sku;
223222
this.source.set(path, row);
224223
}, this);
225224

226225
this.source.set(this.dataScope + '.' + this.index, data);
227226
this.parsePagesData(data);
228227

229228
// Render
230-
dataCount = data.length;
229+
dataCount = tmpData.length;
231230
elemsCount = this.elems().length;
232231

233232
if (dataCount > elemsCount) {
234-
this.getChildItems().each(function (elemData, index) {
233+
tmpData.each(function (elemData, index) {
235234
this.addChild(elemData, this.startIndex + index);
236235
}, this);
237236
} else {
@@ -243,6 +242,15 @@ define([
243242
this.generateAssociatedProducts();
244243
},
245244

245+
/**
246+
* Set initial property to records data
247+
*
248+
* @returns {Object} Chainable.
249+
*/
250+
setInitialProperty: function () {
251+
return this;
252+
},
253+
246254
/**
247255
* Parsed data
248256
*

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<arguments>
3030
<argument name="factoryMapByConfigElementType" xsi:type="array">
3131
<item name="graphql_interface" xsi:type="object">Magento\Framework\GraphQl\Config\Element\InterfaceFactory</item>
32+
<item name="graphql_union" xsi:type="object">Magento\Framework\GraphQl\Config\Element\UnionFactory</item>
3233
<item name="graphql_type" xsi:type="object">Magento\Framework\GraphQl\Config\Element\TypeFactory</item>
3334
<item name="graphql_input" xsi:type="object">Magento\Framework\GraphQl\Config\Element\InputFactory</item>
3435
<item name="graphql_enum" xsi:type="object">Magento\Framework\GraphQl\Config\Element\EnumFactory</item>
@@ -64,6 +65,7 @@
6465
<item name="Magento\Framework\GraphQl\Config\Element\Type" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputTypeObject</item>
6566
<item name="Magento\Framework\GraphQl\Config\Element\Input" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Input\InputObjectType</item>
6667
<item name="Magento\Framework\GraphQl\Config\Element\InterfaceType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputInterfaceObject</item>
68+
<item name="Magento\Framework\GraphQl\Config\Element\UnionType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputUnionObject</item>
6769
<item name="Magento\Framework\GraphQl\Config\Element\Enum" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Enum\Enum</item>
6870
</argument>
6971
</arguments>
@@ -78,13 +80,15 @@
7880
<argument name="formatters" xsi:type="array">
7981
<item name="fields" xsi:type="object">Magento\Framework\GraphQl\Schema\Type\Output\ElementMapper\Formatter\Fields</item>
8082
<item name="interfaces" xsi:type="object">Magento\Framework\GraphQl\Schema\Type\Output\ElementMapper\Formatter\Interfaces</item>
83+
<item name="unions" xsi:type="object">Magento\Framework\GraphQl\Schema\Type\Output\ElementMapper\Formatter\Unions</item>
8184
<item name="resolveType" xsi:type="object">Magento\Framework\GraphQl\Schema\Type\Output\ElementMapper\Formatter\ResolveType</item>
8285
</argument>
8386
</arguments>
8487
</type>
8588
<type name="Magento\Framework\GraphQlSchemaStitching\GraphQlReader\TypeReaderComposite">
8689
<arguments>
8790
<argument name="typeReaders" xsi:type="array">
91+
<item name="union_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\UnionType</item>
8892
<item name="enum_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\EnumType</item>
8993
<item name="object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\ObjectType</item>
9094
<item name="input_object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InputObjectType</item>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ directive @resolver(class: String="") on QUERY
3030
| OBJECT
3131
| FIELD_DEFINITION
3232
| ARGUMENT_DEFINITION
33-
| INTERFACE
34-
| UNION
3533
| ENUM
3634
| ENUM_VALUE
3735
| INPUT_OBJECT
3836
| INPUT_FIELD_DEFINITION
3937

40-
directive @typeResolver(class: String="") on INTERFACE | OBJECT
38+
directive @typeResolver(class: String="") on UNION
39+
| INTERFACE
40+
| OBJECT
4141

4242
directive @cache(cacheIdentity: String="" cacheable: Boolean=true) on QUERY
4343

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,13 +1126,17 @@ define([
11261126
* Update whether value differs from default value
11271127
*/
11281128
setDifferedFromDefault: function () {
1129-
var recordData = utils.copy(this.recordData());
1129+
var recordData;
11301130

1131-
Array.isArray(recordData) && recordData.forEach(function (item) {
1132-
delete item['record_id'];
1133-
});
1131+
if (this.default) {
1132+
recordData = utils.copy(this.recordData());
1133+
1134+
Array.isArray(recordData) && recordData.forEach(function (item) {
1135+
delete item['record_id'];
1136+
});
11341137

1135-
this.isDifferedFromDefault(!_.isEqual(recordData, this.default));
1138+
this.isDifferedFromDefault(!_.isEqual(recordData, this.default));
1139+
}
11361140
},
11371141

11381142
/**

dev/tests/api-functional/_files/Magento/TestModuleGraphQlQuery/Model/Resolver/Item.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
1313

14+
/**
15+
* Resolver for Item
16+
*/
1417
class Item implements ResolverInterface
1518
{
1619
/**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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\TestModuleGraphQlQuery\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Query\ResolverInterface;
12+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13+
14+
/**
15+
* Resolver for Union type TestUnion
16+
*/
17+
class TestUnion implements ResolverInterface
18+
{
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function resolve(
23+
Field $field,
24+
$context,
25+
ResolveInfo $info,
26+
array $value = null,
27+
array $args = null
28+
) {
29+
return [
30+
'custom_name1' => 'custom_name1_value',
31+
'custom_name2' => 'custom_name2_value',
32+
];
33+
}
34+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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\TestModuleGraphQlQuery\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
12+
/**
13+
* Type Resolver for union
14+
*/
15+
class UnionTypeResolver implements TypeResolverInterface
16+
{
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function resolveType(array $data): string
21+
{
22+
if (!empty($data)) {
23+
return 'TypeCustom1';
24+
}
25+
return '';
26+
}
27+
}

dev/tests/api-functional/_files/Magento/TestModuleGraphQlQuery/etc/schema.graphqls

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
type Query {
55
testItem(id: Int!) : Item @resolver(class: "Magento\\TestModuleGraphQlQuery\\Model\\Resolver\\Item")
6+
testUnion: TestUnion @resolver(class: "Magento\\TestModuleGraphQlQuery\\Model\\Resolver\\TestUnion")
67
}
78

89
type Mutation {
@@ -18,3 +19,14 @@ type MutationItem {
1819
item_id: Int
1920
name: String
2021
}
22+
23+
union TestUnion @doc(description: "some kind of union") @typeResolver(class: "Magento\\TestModuleGraphQlQuery\\Model\\Resolver\\UnionTypeResolver") =
24+
TypeCustom1 | TypeCustom2
25+
26+
type TypeCustom1 {
27+
custom_name1: String
28+
}
29+
30+
type TypeCustom2 {
31+
custom_name2: String
32+
}

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQl/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private function processResponseHeaders(string $headers): array
213213

214214
$headerLines = preg_split('/((\r?\n)|(\r\n?))/', $headers);
215215
foreach ($headerLines as $headerLine) {
216-
$headerParts = preg_split('/:/', $headerLine);
216+
$headerParts = preg_split('/: /', $headerLine, 2);
217217
if (count($headerParts) == 2) {
218218
$headersArray[trim($headerParts[0])] = trim($headerParts[1]);
219219
} elseif (preg_match('/HTTP\/[\.0-9]+/', $headerLine)) {

dev/tests/api-functional/testsuite/Magento/GraphQl/CorsHeadersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testCorsHeadersWhenCorsIsEnabled(): void
7676
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_ALLOWED_HEADERS, 'Origin');
7777
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_ALLOW_CREDENTIALS, '1');
7878
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_ALLOWED_METHODS, 'GET,POST');
79-
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_ALLOWED_ORIGINS, 'magento.local');
79+
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_ALLOWED_ORIGINS, 'http://magento.local');
8080
$this->resourceConfig->saveConfig(Configuration::XML_PATH_CORS_MAX_AGE, '86400');
8181
$this->reinitConfig->reinit();
8282

@@ -85,7 +85,7 @@ public function testCorsHeadersWhenCorsIsEnabled(): void
8585
self::assertEquals('Origin', $headers['Access-Control-Allow-Headers']);
8686
self::assertEquals('1', $headers['Access-Control-Allow-Credentials']);
8787
self::assertEquals('GET,POST', $headers['Access-Control-Allow-Methods']);
88-
self::assertEquals('magento.local', $headers['Access-Control-Allow-Origin']);
88+
self::assertEquals('http://magento.local', $headers['Access-Control-Allow-Origin']);
8989
self::assertEquals('86400', $headers['Access-Control-Max-Age']);
9090
}
9191

0 commit comments

Comments
 (0)