Skip to content

Commit 81182ab

Browse files
author
Prabhu Ram
committed
MC-20637: MyAccount :: Order Details :: Invoice Details by Order Number
- refactor and code cleanup
1 parent 9bcd0fc commit 81182ab

File tree

8 files changed

+5
-45
lines changed

8 files changed

+5
-45
lines changed

app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
use Magento\Framework\Api\ExtensibleDataInterface;
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\GraphQl\Config\Element\Field;
13-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1413
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1514
use Magento\Framework\GraphQl\Query\ResolverInterface;
1615
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1716
use Magento\Framework\Serialize\Serializer\Json;
18-
use Magento\GraphQl\Model\Query\ContextInterface;
1917
use Magento\Sales\Api\Data\LineItemInterface;
2018
use Magento\Sales\Api\Data\OrderItemInterface;
2119
use Magento\Sales\Model\Order;
@@ -63,11 +61,6 @@ public function __construct(
6361
*/
6462
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
6563
{
66-
/** @var ContextInterface $context */
67-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
68-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
69-
}
70-
7164
return $this->valueFactory->create(function () use ($value) {
7265
if (!isset($value['model'])) {
7366
throw new LocalizedException(__('"model" value should be specified'));

app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions/SelectedBundleOptionLineItems.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
12-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1312
use Magento\Framework\GraphQl\Query\ResolverInterface;
1413
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15-
use Magento\GraphQl\Model\Query\ContextInterface;
1614

1715
/**
1816
* Resolve line items for Bundle Options
@@ -24,10 +22,6 @@ class SelectedBundleOptionLineItems implements ResolverInterface
2422
*/
2523
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
2624
{
27-
/** @var ContextInterface $context */
28-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
29-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
30-
}
3125
if (!isset($value['items'])) {
3226
throw new LocalizedException(__('"items" value should be specified'));
3327
}

app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions/SelectedBundleOptionItems.php renamed to app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions/SelectedBundleOptionOrderItems.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99

1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
12-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1312
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1413
use Magento\Framework\GraphQl\Query\ResolverInterface;
1514
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
16-
use Magento\GraphQl\Model\Query\ContextInterface;
17-
use Magento\Sales\Model\Order;
1815
use Magento\SalesGraphQl\Model\Resolver\OrderItem\DataProvider as OrderItemProvider;
1916

2017
/**
2118
* Resolve order items for Bundle Options
2219
*/
23-
class SelectedBundleOptionItems implements ResolverInterface
20+
class SelectedBundleOptionOrderItems implements ResolverInterface
2421
{
2522
/**
2623
* @var ValueFactory
@@ -49,10 +46,6 @@ public function __construct(
4946
*/
5047
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
5148
{
52-
/** @var ContextInterface $context */
53-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
54-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
55-
}
5649
if (!isset($value['item_ids'])) {
5750
throw new LocalizedException(__('"item_ids" value should be specified'));
5851
}

app/code/Magento/SalesGraphQl/Model/Resolver/CustomerOrders/Query/OrderFilter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public function applyFilter(
8888
);
8989
$filterGroups[] = $this->filterGroupBuilder->create();
9090

91-
9291
$this->filterGroupBuilder->setFilters(
9392
[$this->filterBuilder->setField('store_id')->setValue($store->getId())->setConditionType('eq')->create()]
9493
);

app/code/Magento/SalesGraphQl/Model/Resolver/InvoiceTotal.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
12-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1312
use Magento\Framework\GraphQl\Query\ResolverInterface;
1413
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15-
use Magento\GraphQl\Model\Query\ContextInterface;
1614
use Magento\Sales\Api\Data\InvoiceInterface as Invoice;
1715
use Magento\Sales\Model\Order;
1816

@@ -31,11 +29,6 @@ public function resolve(
3129
array $value = null,
3230
array $args = null
3331
) {
34-
/** @var ContextInterface $context */
35-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
36-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
37-
}
38-
3932
if (!isset($value['model']) && !($value['model'] instanceof Invoice)) {
4033
throw new LocalizedException(__('"model" value should be specified'));
4134
}

app/code/Magento/SalesGraphQl/Model/Resolver/Invoices.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
12-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1312
use Magento\Framework\GraphQl\Query\ResolverInterface;
1413
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15-
use Magento\GraphQl\Model\Query\ContextInterface;
1614
use Magento\Sales\Model\Order;
1715
use Magento\Sales\Api\Data\InvoiceInterface as Invoice;
1816

@@ -31,12 +29,7 @@ public function resolve(
3129
array $value = null,
3230
array $args = null
3331
) {
34-
/** @var ContextInterface $context */
35-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
36-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
37-
}
38-
39-
if (!isset($value['model']) && !($value['model'] instanceof Order)) {
32+
if (!isset($value['model']) || !($value['model'] instanceof Order)) {
4033
throw new LocalizedException(__('"model" value should be specified'));
4134
}
4235

app/code/Magento/SalesGraphQl/Model/Resolver/LineItems.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,11 @@ public function resolve(
5454
array $value = null,
5555
array $args = null
5656
) {
57-
/** @var ContextInterface $context */
58-
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
59-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
60-
}
61-
62-
if (!isset($value['model']) && !($value['model'] instanceof Invoice)) {
57+
if (!isset($value['model']) || !($value['model'] instanceof Invoice)) {
6358
throw new LocalizedException(__('"model" value should be specified'));
6459
}
6560

66-
if (!isset($value['order']) && !($value['order'] instanceof Order)) {
61+
if (!isset($value['order']) || !($value['order'] instanceof Order)) {
6762
throw new LocalizedException(__('"order" value should be specified'));
6863
}
6964

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type BundleOrderItem implements OrderItemInterface {
8989
type SelectedBundleOptionItems {
9090
id: ID! @doc(description: "The unique identifier of the option")
9191
label: String! @doc(description: "The label of the option")
92-
items: [OrderItem] @doc(description: "A list of products that represent the values of the parent option") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\BundleOptions\\SelectedBundleOptionItems")
92+
items: [OrderItem] @doc(description: "A list of products that represent the values of the parent option") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\BundleOptions\\SelectedBundleOptionOrderItems")
9393
}
9494

9595
type OrderItemOption @doc(description: "Represents order item options like selected or entered") {

0 commit comments

Comments
 (0)