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

Fixed #176 - Show only active CMS Blocks #218

Closed
wants to merge 6 commits into from
Closed

Fixed #176 - Show only active CMS Blocks #218

wants to merge 6 commits into from

Conversation

ronak2ram
Copy link
Member

Description

Removed only active block checking code.

Fixed Issues (if relevant)

  1. Show only active CMS Blocks #176 : Show only active CMS Blocks

Steps to reproduce

  1. Checkout to branch 31-cms-page-graphql-support
    Pull request #31 CMS page/block coverage #105
  2. Disable some CMS block: MagentoAdmin > Content > Blocks > choose_your_block ->
    Enable Block: NO -> Save
  3. Run this GraphQL query:
{
  cmsBlocks (identifiers: ["disabled_cms_block", "enabled_cms_block","not_existed_block"]){
    items{
      title
      identifier
      content
    }
   errors{
      message
   }
  }
}

disabled_cms_block: identifier of the disabled cms_block
enabled_cms_block: identifier of the enabled cms_block

Expected result

  1. Get only cms_blocks with status: enabled.
{
  "data": {
    "cmsBlocks": {
      "items": [
        {
          "title": "Enabled Block",
          "identifier": "enabled_block",
          "content": "<p>g</p>"
        }
      ],
      "errors": {
           [
              "message": "The CMS block with the \"disabled_block\" ID is disabled."
           ],
           [
              "message": "The CMS block with the \"not_existed_block\" ID doesn't exist."
           ],
        }
      }
    }
}

Actual result

{
  "errors": [
    {
      "message": "No such entity.",
      "categoerrorsry": "graphql-no-such-entity",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "cmsBlocks"
      ]
    }
  ],
  "data": {
    "cmsBlocks": 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)

@ronak2ram ronak2ram requested a review from naydav October 20, 2018 07:03
@naydav naydav requested a review from paliarush October 22, 2018 09:19
@@ -32,10 +32,15 @@ type CmsPage @doc(description: "CMS page defines all CMS page information") {

type CmsBlocks @doc(description: "CMS blocks information") {
items: [CmsBlock] @doc(description: "An array of CMS blocks")
errors: [ErrorMessage] @doc(description: "An array of errors message")
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need to introduce "errors" for specific queries. "errors" functionality is available out of the box. All you need to do is to throw \Magento\Framework\GraphQl\Exception\GraphQlInputException or another exception which implements \GraphQL\Error\ClientAware from your resolver.

if (!empty($blockData)) {
$blocksData[$blockIdentifier] = $blockData;
} else {
$this->setErrorMessage(sprintf('The CMS block with the "%s" ID is disabled.', $blockIdentifier));
Copy link
Contributor

Choose a reason for hiding this comment

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

\Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException seems to be suitable here. And please note that it should be translatable (use __())

@ronak2ram ronak2ram closed this Oct 25, 2018
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.

3 participants