Skip to content

[GraphQL] How to get related data in reverse #13349

Closed Answered by brandonkelly
roland-d asked this question in Q&A
Discussion options

You must be logged in to vote

You can accomplish this with Verbb’s Many to Many plugin (free).

Create a new Many to Many field called “Tracks”. Set it to pull in entries from your Tracks section, using the Artists field. Then add the Tracks field to your Artists entry type’s field layout.

With that in place, you’ll be able to start viewing/editing your artist/track relationships from the opposite side, and you’ll be able to start including artists’ tracks in GraphQL queries:

query Artists {
  artistsEntries {
    ... on artists_artist_Entry {
      id
      title
      tracks {
        id
        title
      }
    }
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants