Skip to content

Commit 7cdce40

Browse files
author
Eric Bohanon
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-85687-Graphql-Declarative-schema' into MAGETWO-86320-Graph-Ql-Schema-Implementation
2 parents 6c9f3b7 + d6d7946 commit 7cdce40

File tree

16 files changed

+253
-28
lines changed

16 files changed

+253
-28
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/Formatter/Price.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ private function createAdjustmentsArray(array $adjustments, AmountInterface $amo
8484
foreach ($adjustments as $adjustmentCode => $adjustment) {
8585
if ($amount->hasAdjustment($adjustmentCode) && $amount->getAdjustmentAmount($adjustmentCode)) {
8686
$priceAdjustmentsArray[] = [
87-
'code' => ucfirst($adjustmentCode),
87+
'code' => strtoupper($adjustmentCode),
8888
'amount' => [
8989
'value' => $amount->getAdjustmentAmount($adjustmentCode),
9090
'currency' => $store->getCurrentCurrencyCode(),
9191
],
9292
'description' => $adjustment->isIncludedInDisplayPrice() ?
93-
'Included' : 'Excluded'
93+
'INCLUDED' : 'EXCLUDED'
9494
];
9595
}
9696
}

app/code/Magento/CatalogGraphQl/etc/graphql.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,10 @@
185185
<item name="trl">TRL</item>
186186
<item name="xpf">XPF</item>
187187
</type>
188-
<type xsi:type="Enum" name="PriceAdjustmentCodesEnum">
189-
<item name="tax">Tax</item>
190-
<item name="wee">Wee</item>
191-
<item name="wee_tax">WeeTax</item>
192-
</type>
188+
<type xsi:type="Enum" name="PriceAdjustmentCodesEnum"/>
193189
<type xsi:type="Enum" name="PriceAdjustmentDescriptionEnum">
194-
<item name="included">Included</item>
195-
<item name="excluded">Excluded</item>
190+
<item name="included">INCLUDED</item>
191+
<item name="excluded">EXCLUDED</item>
196192
</type>
197193
<type xsi:type="OutputType" name="Money">
198194
<field xsi:type="ScalarOutputField" name="value" type="Float"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<field xsi:type="ObjectInputField" name="url_path" type="SortEnum"/>
1818
</type>
1919
<type xsi:type="Enum" name="UrlRewriteEntityTypeEnum">
20-
<item name="PRODUCT">PRODUCT</item>
21-
<item name="CATEGORY">CATEGORY</item>
20+
<item name="product">PRODUCT</item>
21+
<item name="category">CATEGORY</item>
2222
</type>
2323
</config>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
-->
66
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_GraphQl:etc/graphql.xsd">
77
<type xsi:type="Enum" name="UrlRewriteEntityTypeEnum">
8-
<item name="CMS_PAGE">CMS_PAGE</item>
8+
<item name="cms_page">CMS_PAGE</item>
99
</type>
1010
</config>

app/code/Magento/TaxGraphQl/etc/graphql.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
<type xsi:type="InputType" name="ProductSortInput">
1414
<field xsi:type="ObjectInputField" name="tax_class_id" type="SortEnum"/>
1515
</type>
16+
<type xsi:type="Enum" name="PriceAdjustmentCodesEnum">
17+
<item name="tax">TAX</item>
18+
</type>
1619
</config>

app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@ public function resolve(array $args, ResolverContextInterface $context)
6565
*/
6666
private function findCanonicalUrl(string $requestPath)
6767
{
68-
$urlRewrite = $this->findUrl($requestPath);
69-
if ($urlRewrite->getRedirectType() > 0) {
68+
$urlRewrite = $this->findUrlFromRequestPath($requestPath);
69+
if ($urlRewrite && $urlRewrite->getRedirectType() > 0) {
7070
while ($urlRewrite && $urlRewrite->getRedirectType() > 0) {
71-
$urlRewrite = $this->findUrl($urlRewrite->getTargetPath());
71+
$urlRewrite = $this->findUrlFromRequestPath($urlRewrite->getTargetPath());
7272
}
7373
}
74+
if (!$urlRewrite) {
75+
$urlRewrite = $this->findUrlFromTargetPath($requestPath);
76+
}
7477
return $urlRewrite;
7578
}
7679

@@ -80,7 +83,7 @@ private function findCanonicalUrl(string $requestPath)
8083
* @param string $requestPath
8184
* @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|null
8285
*/
83-
private function findUrl(string $requestPath)
86+
private function findUrlFromRequestPath(string $requestPath)
8487
{
8588
return $this->urlFinder->findOneByData(
8689
[
@@ -90,6 +93,22 @@ private function findUrl(string $requestPath)
9093
);
9194
}
9295

96+
/**
97+
* Find a url from a target url on the current store
98+
*
99+
* @param string $targetPath
100+
* @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|null
101+
*/
102+
private function findUrlFromTargetPath(string $targetPath)
103+
{
104+
return $this->urlFinder->findOneByData(
105+
[
106+
'target_path' => $targetPath,
107+
'store_id' => $this->storeManager->getStore()->getId()
108+
]
109+
);
110+
}
111+
93112
/**
94113
* Sanitizes the type to fit schema specs
95114
*

app/code/Magento/UrlRewriteGraphQl/etc/graphql.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_GraphQl:etc/graphql.xsd">
77
<type xsi:type="OutputType" name="Query">
88
<field xsi:type="ObjectOutputField" name="urlResolver" type="EntityUrl" resolver="Magento\UrlRewriteGraphQl\Model\Resolver\UrlRewrite">
9-
<argument xsi:type="ScalarArgument" name="url" type="String"/>
9+
<argument xsi:type="ScalarArgument" name="url" type="String" required="true"/>
1010
</field>
1111
</type>
1212
<type xsi:type="OutputType" name="EntityUrl">
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# WeeeGraphQl
2+
3+
**WeeeGraphQl** provides type information for the GraphQl module
4+
to generate wee tax fields for catalog and product information endpoints.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "magento/module-weee-graph-ql",
3+
"description": "N/A",
4+
"type": "magento2-module",
5+
"version": "100.0.0-dev",
6+
"require": {
7+
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
8+
"magento/framework": "100.3.*"
9+
},
10+
"suggest": {
11+
"magento/module-weee": "100.3.*",
12+
"magento/module-catalog-graph-ql": "100.0.*"
13+
},
14+
"license": [
15+
"OSL-3.0",
16+
"AFL-3.0"
17+
],
18+
"autoload": {
19+
"files": [
20+
"registration.php"
21+
],
22+
"psr-4": {
23+
"Magento\\WeeeGraphQl\\": ""
24+
}
25+
}
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright © Magento, Inc. All rights reserved.
4+
See COPYING.txt for license details.
5+
-->
6+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_GraphQl:etc/graphql.xsd">
7+
<type xsi:type="Enum" name="PriceAdjustmentCodesEnum">
8+
<item name="wee">WEE</item>
9+
<item name="wee_tax">WEETAX</item>
10+
</type>
11+
</config>

0 commit comments

Comments
 (0)