0

I have two Entry types: Albums and Songs. On the Albums entry type, I have a SuperTable field (called tracklist) where you can add tracks and select one Song entry per row.

On the song page, I'd like to query a list of all the albums that have that song in their tracklist (e.g. "Hey Jude appears up on these three albums…").

I discovered how to get all the albums related to a song like so:

entries(section: "albums", relatedToEntries: [{section: "songs", id: "54"}]) {
  slug
  title
}

This, however, returns an empty array since the relational field is buried within the tracklist SuperTable field.

The Relations docs suggest that this should be possible, but I'm pretty confused how to make this query via GraphQL (the docs there are rather sparse).

I'm assuming the query will need to know where to find the relational field on the album entry. Something like this seems pretty close, but I'm getting a 500 error:

entries(section: "albums", relatedTo: [
  {sourceElement: "albums", field: "tracklist.song"}
  {targetElement: "songs", id: "54"}
]) {
  slug
  title
}

Any tips?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy