Skip to content

GraphQl Media gallery returns disabled entries. #34342

Open
@Hexmage

Description

@Hexmage

Summary (*)

When you request a product through GraphQl you always receive all images in the media gallery even if they are disabled for showing on the product page. This is normally fine, because each image also shows if it's disabled.

If you have only 1 enabled image you don't want to show a gallery, you'd instead want to show just the enabled image. But there is no way to check how many enabled images are returned, except by looping through all of them.

Examples (*)

Example of the response to a product request:

{
  "data": {
    "productDetail": {
      "items": [
        {
          "media_gallery_entries": [
            {
              "label": null,
              "position": 1,
              "disabled": true,
              "file": "\/1\/6\/16683.png",
              "__typename": "MediaGalleryEntry"
            },
            {
              "label": "16683",
              "position": 2,
              "disabled": false,
              "file": "\/1\/6\/16683_1.png",
              "__typename": "MediaGalleryEntry"
            }
          ],
        }
      ],
    }
  }
}

This results in a gallery with 1 item, which is not desirable.
Screenshot from 2021-10-14 11-08-21

Proposed solution

Don't return the disabled media gallery entries through GraphQl. They won't be used because they are disabled, so why return them. Instead the storefront can be made simpeler, because you don't have to check if the image is actually enabled or not.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Type

No type

Projects

Status

Pull Request in Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions