Skip to content

Commit a5d0ce6

Browse files
author
Eric Bohanon
committed
MAGETWO-82674: GraphQL Full Text Search
1 parent 16da117 commit a5d0ce6

File tree

13 files changed

+376
-324
lines changed

13 files changed

+376
-324
lines changed

app/code/Magento/GraphQl/Model/EntityAttributeList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
) {
3838
$this->management = $management;
3939
$this->eavSetupFactory = $eavSetupFactory;
40-
$this->eavSetup = $eavSetup = $this->eavSetupFactory->create();
40+
$this->eavSetup = $this->eavSetupFactory->create();
4141
}
4242

4343
public function getDefaultEntityAttributes(string $entityCode)

app/code/Magento/GraphQl/Model/FieldConfig.php

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,7 @@ public function getFieldConfig(string $fieldName, array $arguments)
5252
return $this->instances[$fieldName];
5353
}
5454
if (isset($this->config[$fieldName])) {
55-
$this->instances[$fieldName] = [];
56-
foreach ($this->config[$fieldName] as $argumentName => $fieldConfig) {
57-
$this->instances[$fieldName][$argumentName] = $this->argumentConfigFactory->create(
58-
[
59-
'defaultValue' => isset($fieldConfig['defaultValue']) ? $fieldConfig['defaultValue'] : null,
60-
'valueParser'=> isset($fieldConfig['valueParser'])
61-
? $fieldConfig['valueParser']
62-
: null
63-
]
64-
);
65-
}
66-
foreach ($arguments as $argumentName => $argumentValue) {
67-
if (!isset($this->instances[$fieldName][$argumentName])) {
68-
$this->instances[$fieldName][$argumentName] = $this->argumentConfigFactory->create(
69-
[
70-
'defaultValue' => null,
71-
'valueParser'=> null
72-
]
73-
);
74-
}
75-
}
55+
$this->processConfiguredField($fieldName, $arguments);
7656
} else {
7757
foreach (array_keys($arguments) as $argument) {
7858
$this->instances[$fieldName][$argument] = $this->argumentConfigFactory->create([
@@ -88,4 +68,29 @@ public function getFieldConfig(string $fieldName, array $arguments)
8868
return [];
8969
}
9070
}
71+
72+
private function processConfiguredField(string $fieldName, array $arguments)
73+
{
74+
$this->instances[$fieldName] = [];
75+
foreach ($this->config[$fieldName] as $argumentName => $fieldConfig) {
76+
$this->instances[$fieldName][$argumentName] = $this->argumentConfigFactory->create(
77+
[
78+
'defaultValue' => isset($fieldConfig['defaultValue']) ? $fieldConfig['defaultValue'] : null,
79+
'valueParser'=> isset($fieldConfig['valueParser'])
80+
? $fieldConfig['valueParser']
81+
: null
82+
]
83+
);
84+
}
85+
foreach (array_keys($arguments) as $argumentName) {
86+
if (!isset($this->instances[$fieldName][$argumentName])) {
87+
$this->instances[$fieldName][$argumentName] = $this->argumentConfigFactory->create(
88+
[
89+
'defaultValue' => null,
90+
'valueParser'=> null
91+
]
92+
);
93+
}
94+
}
95+
}
9196
}

app/code/Magento/GraphQl/Model/ResolverContext.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ public function getExtensionAttributes()
7777
* @param \Magento\GraphQl\Model\ResolverContextExtensionInterface $extensionAttributes
7878
* @return $this
7979
*/
80-
public function setExtensionAttributes(\Magento\GraphQl\Model\ResolverContextExtensionInterface $extensionAttributes)
81-
{
80+
public function setExtensionAttributes(
81+
\Magento\GraphQl\Model\ResolverContextExtensionInterface $extensionAttributes
82+
) {
8283
return $this->_setExtensionAttributes($extensionAttributes);
8384
}
8485

app/code/Magento/GraphQl/Model/Type/Handler/Pool/Complex.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
namespace Magento\GraphQl\Model\Type\Handler\Pool;
8+
89
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
910
use Magento\Framework\GraphQl\Type\Definition\TypeInterface;
1011
use Magento\GraphQl\Model\Type\HandlerConfig;

app/code/Magento/GraphQl/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"version": "100.0.0-dev",
66
"require": {
77
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
8+
"magento/module-authorization": "100.3.*",
89
"magento/module-webapi": "100.3.*",
10+
"magento/module-eav": "100.3.*",
911
"magento/framework": "100.3.*"
1012
},
1113
"license": [

app/code/Magento/GraphQlCatalog/Model/Resolver/Products/Query/PostFetchProcessorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ interface PostFetchProcessorInterface
1818
* @return array
1919
*/
2020
public function process(array $productData);
21-
}
21+
}

app/code/Magento/GraphQlCatalog/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"magento/module-eav": "100.3.*",
99
"magento/module-catalog": "100.2.*",
1010
"magento/module-graph-ql": "100.0.*",
11+
"magento/module-search": "100.3.*",
1112
"magento/framework": "100.3.*"
1213
},
1314
"license": [

app/code/Magento/GraphQlConfigurableProduct/Model/Plugin/Model/Resolver/Products/DataProvider/ProductPlugin.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Api\SearchCriteriaBuilder;
1717
use Magento\Framework\Api\SearchResultsInterface;
1818
use Magento\Framework\Api\SearchResultsInterfaceFactory;
19+
use Magento\Framework\DataObject;
1920
use Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider\Product;
2021
use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute;
2122

@@ -96,6 +97,21 @@ public function afterGetList(Product $subject, SearchResultsInterface $result)
9697
$attributes = $this->attributeCollection->getItems();
9798
}
9899

100+
$result = $this->addConfigurableData($result, $children, $attributes);
101+
102+
return $result;
103+
}
104+
105+
/**
106+
* Add configurable data to any configurable products in result set
107+
*
108+
* @param SearchResultsInterface $result
109+
* @param DataObject[] $children
110+
* @param DataObject[] $attributes
111+
* @return SearchResultsInterface
112+
*/
113+
private function addConfigurableData($result, $children, $attributes)
114+
{
99115
foreach ($result->getItems() as $product) {
100116
if ($product->getTypeId() === Configurable::TYPE_CODE) {
101117
$extensionAttributes = $product->getExtensionAttributes();

app/code/Magento/GraphQlConfigurableProduct/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
88
"magento/module-eav": "100.3.*",
99
"magento/module-catalog": "100.2.*",
10-
"magento/module-configurable-product": "100.3.*",
1110
"magento/module-graph-ql": "100.0.*",
11+
"magento/module-graph-ql-catalog": "100.0.*",
1212
"magento/framework": "100.3.*"
1313
},
1414
"license": [

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
"magento/module-google-analytics": "100.3.0-dev",
138138
"magento/module-google-optimizer": "100.3.0-dev",
139139
"magento/module-graph-ql": "100.0.0-dev",
140+
"magento/module-graph-ql-catalog": "100.0.0-dev",
141+
"magento/module-graph-ql-configurable-product": "100.0.0-dev",
142+
"magento/module-graph-ql-customer": "100.0.0-dev",
143+
"magento/module-graph-ql-eav": "100.0.0-dev",
140144
"magento/module-grouped-import-export": "100.3.0-dev",
141145
"magento/module-grouped-product": "100.3.0-dev",
142146
"magento/module-import-export": "100.3.0-dev",

0 commit comments

Comments
 (0)