Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Fixed non existant category with products issue #311

Conversation

ldusan84
Copy link
Contributor

@ldusan84 ldusan84 commented Jan 3, 2019

Description (*)

The category query for category that doesn't exist with products count shouldn't throw an error.

Fixed Issues (if relevant)

  1. Non existent category with products query results in an error #310: Non existent category with products query results in an error

Manual testing scenarios (*)

  1. Query:
{
  category(id: 99) {
    product_count
  }
}
  1. Result
{
  "data": {
    "category": null
  }
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jan 3, 2019

CLA assistant check
All committers have signed the CLA.

@@ -72,7 +72,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value

$rootCategoryId = $this->getCategoryId($args);
$categoriesTree = $this->categoryTree->getTree($info, $rootCategoryId);
if (!empty($categoriesTree)) {
if (!empty($categoriesTree) && ($categoriesTree->count() > 0)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!empty($categoriesTree) && $categoriesTree->count()) {

QUERY;

$response = $this->graphQlQuery($query);
$expectedResponse = ['category' => null];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be better to back some error like Category doesn't exist

Example for CMS page
https://github.com/magento/graphql-ce/blob/2.3-develop/app/code/Magento/CmsGraphQl/Model/Resolver/Page.php#L77

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naydav that's done.

@ldusan84 ldusan84 force-pushed the feature/category-with-products-fix branch from 8b4f751 to 996ba90 Compare February 15, 2019 14:13
@naydav naydav added the bug Something isn't working label Feb 20, 2019
@magento-engcom-team magento-engcom-team merged commit 996ba90 into magento:2.3-develop Mar 13, 2019
@ghost
Copy link

ghost commented Mar 13, 2019

Hi @ldusan84, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants