Skip to content

Commit 42c6116

Browse files
committed
Revert GraphQL-727: currentPage: 0, currentPage: 1 and currentPage: -1 produces the same output for products query when filtering is used
1 parent 532edf7 commit 42c6116

File tree

4 files changed

+792
-872
lines changed

4 files changed

+792
-872
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Category/Products.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ public function resolve(
6666
]
6767
];
6868
$searchCriteria = $this->searchCriteriaBuilder->build($field->getName(), $args);
69-
if ($args['currentPage'] < 1) {
70-
throw new GraphQlInputException(__('currentPage value must be greater than 0.'));
71-
}
72-
if ($args['pageSize'] < 1) {
73-
throw new GraphQlInputException(__('pageSize value must be greater than 0.'));
74-
}
75-
7669
$searchCriteria->setCurrentPage($args['currentPage']);
7770
$searchCriteria->setPageSize($args['pageSize']);
7871
$searchResult = $this->filterQuery->getResult($searchCriteria, $info);

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ public function resolve(
7171
array $args = null
7272
) {
7373
$searchCriteria = $this->searchCriteriaBuilder->build($field->getName(), $args);
74-
if ($args['currentPage'] < 1) {
75-
throw new GraphQlInputException(__('currentPage value must be greater than 0.'));
76-
}
77-
if ($args['pageSize'] < 1) {
78-
throw new GraphQlInputException(__('pageSize value must be greater than 0.'));
79-
}
80-
8174
$searchCriteria->setCurrentPage($args['currentPage']);
8275
$searchCriteria->setPageSize($args['pageSize']);
8376
if (!isset($args['search']) && !isset($args['filter'])) {

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,8 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381381
}
382382
QUERY;
383383
$this->expectException(\Exception::class);
384-
$this->expectExceptionMessage(
385-
'GraphQL response contains errors: currentPage value 2 specified is greater ' .
386-
'than the 1 page(s) available'
387-
);
384+
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 2 specified is greater ' .
385+
'than the 1 page(s) available');
388386
$this->graphQlQuery($query);
389387
}
390388

@@ -1045,10 +1043,8 @@ public function testQueryPageOutOfBoundException()
10451043
QUERY;
10461044

10471045
$this->expectException(\Exception::class);
1048-
$this->expectExceptionMessage(
1049-
'GraphQL response contains errors: currentPage value 2 specified is greater ' .
1050-
'than the 1 page(s) available.'
1051-
);
1046+
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 2 specified is greater ' .
1047+
'than the 1 page(s) available.');
10521048
$this->graphQlQuery($query);
10531049
}
10541050

@@ -1079,10 +1075,8 @@ public function testQueryWithNoSearchOrFilterArgumentException()
10791075
QUERY;
10801076

10811077
$this->expectException(\Exception::class);
1082-
$this->expectExceptionMessage(
1083-
'GraphQL response contains errors: \'search\' or \'filter\' input argument is ' .
1084-
'required.'
1085-
);
1078+
$this->expectExceptionMessage('GraphQL response contains errors: \'search\' or \'filter\' input argument is ' .
1079+
'required.');
10861080
$this->graphQlQuery($query);
10871081
}
10881082

@@ -1137,66 +1131,6 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
11371131
$this->assertEquals(1, $response['products']['total_count']);
11381132
}
11391133

1140-
/**
1141-
* Verify that invalid page numbers return an error
1142-
*
1143-
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1144-
* @expectedException \Exception
1145-
* @expectedExceptionMessage currentPage value must be greater than 0
1146-
*/
1147-
public function testInvalidPageNumbers()
1148-
{
1149-
$query = <<<QUERY
1150-
{
1151-
products (
1152-
filter: {
1153-
sku: {
1154-
like:"simple%"
1155-
}
1156-
}
1157-
pageSize: 4
1158-
currentPage: 0
1159-
) {
1160-
items {
1161-
sku
1162-
}
1163-
}
1164-
}
1165-
QUERY;
1166-
1167-
$this->graphQlQuery($query);
1168-
}
1169-
1170-
/**
1171-
* Verify that invalid page size returns an error
1172-
*
1173-
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1174-
* @expectedException \Exception
1175-
* @expectedExceptionMessage pageSize value must be greater than 0
1176-
*/
1177-
public function testInvalidPageSize()
1178-
{
1179-
$query = <<<QUERY
1180-
{
1181-
products (
1182-
filter: {
1183-
sku: {
1184-
like:"simple%"
1185-
}
1186-
}
1187-
pageSize: 0
1188-
currentPage: 1
1189-
) {
1190-
items {
1191-
sku
1192-
}
1193-
}
1194-
}
1195-
QUERY;
1196-
1197-
$this->graphQlQuery($query);
1198-
}
1199-
12001134
/**
12011135
* Asserts the different fields of items returned after search query is executed
12021136
*

0 commit comments

Comments
 (0)