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

[5.x]: How to do eager loading of asset inside Matrix field entry type? #14819

Closed
agosman opened this issue Apr 16, 2024 · 5 comments
Closed
Labels

Comments

@agosman
Copy link

agosman commented Apr 16, 2024

What happened?

Description

When fetching a Matrix field via GraphQL, how would one also fetch nested asset fields inside of one of its entry types?
Currently, an empty array is returned. I suppose this has to do with having to define eager loading, but I can't find anything on it in the GraphQL API.

Thanks.

Craft CMS version

5.0.4

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@agosman agosman added the bug label Apr 16, 2024
@agosman agosman changed the title [5.x]: How to do ager loading of asset inside Matrix field entry type? [5.x]: How to do eager loading of asset inside Matrix field entry type? Apr 16, 2024
@brandonkelly
Copy link
Member

Can you post the GraphQL query you’re using?

@agosman
Copy link
Author

agosman commented Apr 17, 2024

Sure. The actual query is more elaborate and uses nested fragments but for the sake of simplicity, this query also returns an empty array:

query homepage {
  entry(section: "home") {
    id
    title
    ...on home_Entry {
      modulesMatrix {
        ...on visualModule_Entry {
          id
          visual {
            id
            url
          }
        }
      }
    }
  }
}

@brandonkelly
Copy link
Member

Thanks! I was able to reproduce, and fixed for the next release.

You can pull in the fix ahead of time by changing your craftcms/cms requirement in composer.json to "5.x-dev as 5.0.4" and running composer update.

@agosman
Copy link
Author

agosman commented Apr 18, 2024

Thanks!

@brandonkelly
Copy link
Member

Craft 5.0.5 is out with that fix. Thanks again!

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

No branches or pull requests

2 participants