Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset transforms (in nested blocks) do not work with GraphQL queries #638

Open
jesuismaxime opened this issue Aug 15, 2022 · 7 comments
Open

Comments

@jesuismaxime
Copy link

Description

Transforms on Asset field (in nested blocks) aren't working as expected.

The following segment work fine in relation fields (see relationEntryPage above) but is doing a fit instead a crop on a direct block field

 image @transform(mode: "crop", width: 1440, height: 810, quality: 100, position: "center-center") {
                    url
                    width
                    height
                    mimeType
                    srcset(sizes: ["360w", "1024w", "720w", "1440w", "1920w", "2048w", "2880w"])
                  }
The GQL query
{
  entry(section: "home") {
    ... on home_home_Entry {
      sections: layout {
        ... on layout_BlockSection_BlockType {
          children {
            ... on layout_BlockCtaNextPage_BlockType {
              relationEntryPage {
                ... on page_default_Entry {
                  image @transform(mode: "crop", width: 1440, height: 810, quality: 100, position: "center-center") {
                    url
                    width
                    height
                    mimeType
                    srcset(sizes: ["360w", "1024w", "720w", "1440w", "1920w", "2048w", "2880w"])
                  }
                }
              }
              image @transform(mode: "crop", width: 1440, height: 810, quality: 100, position: "center-center") {
                url
                width
                height
                mimeType
                srcset(sizes: ["360w", "1024w", "720w", "1440w", "1920w", "2048w", "2880w"])
              }
            }
          }
        }
      }
    }
  }
}
The Result
{
  "data": {
    "entry": {
      "sections": [
        {
          "children": [
            {
              "relationEntryPage": [
                {
                  "image": [
                    {
                      "url": "http://my.local.url/medias/transforms/images/_1440x810_crop_center-center_100_none/equipe-sportive.jpg",
                      "width": 1440,
                      "height": 810,
                      "mimeType": "image/jpeg",
                      "srcset": "http://my.local.url/medias/transforms/images/_360x203_crop_center-center_100_none/equipe-sportive.jpg 360w, http://my.local.url/medias/transforms/images/_1024x576_crop_center-center_100_none/equipe-sportive.jpg 1024w, http://my.local.url/medias/transforms/images/_720x405_crop_center-center_100_none/equipe-sportive.jpg 720w, http://my.local.url/medias/transforms/images/_1440x810_crop_center-center_100_none/equipe-sportive.jpg 1440w, http://my.local.url/medias/transforms/images/_1920x1080_crop_center-center_100_none/equipe-sportive.jpg 1920w, http://my.local.url/medias/transforms/images/_2048x1152_crop_center-center_100_none/equipe-sportive.jpg 2048w, http://my.local.url/medias/transforms/images/_2880x1620_crop_center-center_100_none/equipe-sportive.jpg 2880w"
                    }
                  ]
                }
              ],
              "image": [
                {
                  "url": "http://my.local.url/medias/images/MER-equipes-sportives.jpg",
                  "width": 3000,
                  "height": 1626,
                  "mimeType": "image/jpeg",
                  "srcset": "http://my.local.url/medias/transforms/images/_360xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 360w, http://my.local.url/medias/transforms/images/_1024xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 1024w, http://my.local.url/medias/transforms/images/_720xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 720w, http://my.local.url/medias/transforms/images/_1440xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 1440w, http://my.local.url/medias/transforms/images/_1920xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 1920w, http://my.local.url/medias/transforms/images/_2048xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 2048w, http://my.local.url/medias/transforms/images/_2880xAUTO_crop_center-center_none/MER-equipes-sportives.jpg 2880w"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

As you can see above; the first image (link to a page through relationEntryPage is working fine, the image is crop. But in the second image (image field attach to the block layout_BlockCtaNextPage_BlockType is doing a resize.

The issue also appear on other blocks in our layout field. So this is not isloated to one block. Plus; it appears on all our local machine + our staging environment.

The query above was tested in GraphiQL interface, so this is not a "front-end" issue.

Other information

  • Neo version: 3.2.5
  • Craft version: 4.2.1
@ttempleton
Copy link
Contributor

So far, I've found that this line in Craft returns an empty array for this query, making the eager loading break down. That means Transform::apply() is given an asset query instead of a collection, and returns without applying the transforms.

I'm not yet sure if the issue is on Neo's or Craft's end, though, but I'll keep looking into it.

@ttempleton
Copy link
Contributor

Just wanted to update that I've made progress on this today which seems to be working. Will need to do more testing to make sure it hasn't had any undesired side effects, but hopefully I can release the fix by the end of the week.

@ttempleton
Copy link
Contributor

Just released Neo 3.3.6 with the fix for this.

@jesuismaxime
Copy link
Author

Is there any possibility that this issue came back?

Got the same behavior with latest Craft and Neo relase!

@ttempleton
Copy link
Contributor

I've just tested this and it worked as expected. Can you confirm whether this happens if you set up a test from a fresh Craft install?

@jesuismaxime
Copy link
Author

Me again, the issue has made a comeback on a new project, Craft CMS v4.10.7, Neo v4.2.9

@ttempleton
Copy link
Contributor

@jesuismaxime if you're able to reliably reproduce that with GraphiQL, if possible could you please send your Composer files, database backup, and example GraphQL query to [email protected] and I'll have a look.

@ttempleton ttempleton reopened this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants