Skip to content

Commit cb354b0

Browse files
committed
MAGETWO-81034: API for fetching multiple products
- static fixes
1 parent 44e2e3e commit cb354b0

File tree

11 files changed

+31
-24
lines changed

11 files changed

+31
-24
lines changed

app/code/Magento/GraphQl/Model/GraphQl/Clause/ReferenceTypeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
}
2828

2929
/**
30-
* Creates a ReferenceType
30+
* Create ReferenceType
3131
*
3232
* @param string $entityType
3333
* @param string|null $linkField

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
}
2929

3030
/**
31-
* Creates a clause
31+
* Create a clause
3232
*
3333
* @param ReferenceType $referenceType
3434
* @param string $fieldName

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
$this->objectManager = $objectManager;
2727
}
2828
/**
29-
* Creates a connective class
29+
* Create a connective class
3030
*
3131
* @param array $conditions
3232
* @param string|null $operator

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\GraphQl\Model\GraphQl;
77

8+
/**
9+
* Class Operator
10+
*/
811
class Operator
912
{
1013
/**

app/code/Magento/GraphQl/Model/Resolver/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function resolve(array $args, ResolveInfo $info)
7272
}
7373

7474
/**
75-
* Resolves product by Sku
75+
* Resolve product by Sku
7676
*
7777
* @param string $sku
7878
* @return array|null
@@ -89,7 +89,7 @@ public function getProduct(string $sku)
8989
}
9090

9191
/**
92-
* Resolves product by Id
92+
* Resolve product by Id
9393
*
9494
* @param int $productId
9595
* @return array|null

app/code/Magento/GraphQl/Model/Resolver/Products.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
use Magento\Catalog\Api\ProductRepositoryInterface;
1010
use GraphQL\Type\Definition\ResolveInfo;
1111
use Magento\GraphQl\Model\ResolverInterface;
12+
use Magento\GraphQl\Model\Resolver\Products\SearchCriteriaFactory;
1213

1314
/**
14-
* Product field resolver, used for GraphQL request processing.
15+
* Products field resolver, used for GraphQL request processing.
1516
*/
1617
class Products implements ResolverInterface
1718
{
@@ -20,7 +21,7 @@ class Products implements ResolverInterface
2021
*/
2122
private $productRepository;
2223

23-
/** @var \Magento\GraphQl\Model\Resolver\Products\SearchCriteriaFactory */
24+
/** @var SearchCriteriaFactory */
2425
private $searchCriteriaFactory;
2526

2627
/**
@@ -54,7 +55,7 @@ public function resolve(array $args, ResolveInfo $info)
5455
}
5556

5657
$maxPages = ceil($itemsResults->getTotalCount() / $searchCriteria->getPageSize());
57-
if ($searchCriteria->getCurrentPage() > $maxPages) {
58+
if ($searchCriteria->getCurrentPage() > $maxPages && $itemsResults->getTotalCount() > 0) {
5859
throw new \GraphQL\Error\Error(sprintf('Current page is bigger than maximum %s', $maxPages));
5960
}
6061

app/code/Magento/GraphQl/Model/Resolver/Products/FilterGroupFactory.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@
1010
use Magento\GraphQl\Model\GraphQl\Clause;
1111
use Magento\GraphQl\Model\GraphQl\Connective;
1212
use Magento\GraphQl\Model\GraphQl\Operator;
13+
use Magento\Framework\Api\FilterBuilder;
14+
use Magento\Framework\Api\Search\FilterGroupBuilder;
1315

1416
/**
15-
* Product field resolver, used for GraphQL request processing.
17+
* Class FilterGroupFactory
1618
*/
1719
class FilterGroupFactory
1820
{
19-
/** @var \Magento\Framework\Api\FilterBuilder */
21+
/** @var FilterBuilder */
2022
private $filterBuilder;
2123

22-
/** @var \Magento\Framework\Api\Search\FilterGroupBuilder */
24+
/** @var FilterGroupBuilder */
2325
private $filterGroupBuilder;
2426

25-
/** @var \Magento\GraphQl\Model\Resolver\Products\ProductFilterResolver */
27+
/** @var ProductFilterResolver */
2628
private $filterResolver;
2729

2830
/**
@@ -41,7 +43,7 @@ public function __construct(
4143
}
4244

4345
/**
44-
* Creates a filter groups from an AST
46+
* Create a filter groups from an AST
4547
*
4648
* @param ResolveInfo $info
4749
* @return \Magento\Framework\Api\Search\FilterGroup[]
@@ -88,7 +90,7 @@ public function create(ResolveInfo $info)
8890
}
8991

9092
/**
91-
* Processes an AST Connective
93+
* Process an AST Connective
9294
*
9395
* @param Connective $connective
9496
* @return \Magento\Framework\Api\Search\FilterGroup
@@ -114,7 +116,7 @@ private function processConnective(Connective $connective)
114116
}
115117

116118
/**
117-
* Processes an AST Clause
119+
* Process an AST Clause
118120
*
119121
* @param Clause $clause
120122
* @return \Magento\Framework\Api\Search\FilterGroup

app/code/Magento/GraphQl/Model/Resolver/Products/ProductFilterResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Magento\GraphQl\Model\Type\Helper\ServiceContract\TypeGenerator;
1818

1919
/**
20-
* Class Product FilterResolver
20+
* Product field resolver, used for GraphQL request processing
2121
*/
2222
class ProductFilterResolver
2323
{
@@ -68,7 +68,7 @@ public function __construct(
6868
}
6969

7070
/**
71-
* Gets a clause from an AST
71+
* Get a clause from an AST
7272
*
7373
* @param ReferenceType $referenceType
7474
* @param NodeList $nodeList
@@ -109,7 +109,7 @@ private function getClausesFromAst(ReferenceType $referenceType, NodeList $nodeL
109109
}
110110

111111
/**
112-
* Gets the fields from catalog product
112+
* Get the fields from catalog product
113113
*
114114
* @return array
115115
*/
@@ -135,7 +135,7 @@ private function getCatalogProductFields()
135135
}
136136

137137
/**
138-
* Gets a connective filter from an AST
138+
* Get a connective filter from an AST
139139
*
140140
* @param string $entityType
141141
* @param SelectionNode $node

app/code/Magento/GraphQl/Model/Resolver/Products/SearchCriteriaFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
use Magento\Framework\Api\SortOrder;
1010
use Magento\Framework\Api\SortOrderBuilder;
1111
use GraphQL\Type\Definition\ResolveInfo;
12+
use Magento\Framework\Api\SearchCriteriaInterfaceFactory;
1213

1314
/**
14-
* Product field resolver, used for GraphQL request processing.
15+
* Create a search criteria from AST.
1516
*/
1617
class SearchCriteriaFactory
1718
{
1819
const DEFAULT_PAGE_SIZE = 20;
1920

20-
/** @var \Magento\Framework\Api\SearchCriteriaInterfaceFactory */
21+
/** @var SearchCriteriaInterfaceFactory */
2122
private $searchCriteriaFactory;
2223

2324
/** @var SortOrderBuilder */
@@ -42,7 +43,7 @@ public function __construct(
4243
}
4344

4445
/**
45-
* Creates a search criteria from an AST
46+
* Create a search criteria from an AST method
4647
*
4748
* @param ResolveInfo $info
4849
* @return \Magento\Framework\Api\SearchCriteriaInterface

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\GraphQl\Model\ResolverFactory;
1414

1515
/**
16-
* Generates query field and concrete types for GraphQL scehma
16+
* Generate a query field and concrete types for GraphQL schema
1717
*/
1818
class SchemaGenerator implements SchemaGeneratorInterface
1919
{

0 commit comments

Comments
 (0)