Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Ability to access reverse relations within entry query in GQL #7110

Closed
andrewfairlie opened this issue Nov 9, 2020 · 7 comments
Closed

Ability to access reverse relations within entry query in GQL #7110

andrewfairlie opened this issue Nov 9, 2020 · 7 comments
Assignees
Labels
enhancement improvements to existing features graphql ⚙️ features related to the GraphQL API

Comments

@andrewfairlie
Copy link

It would be really useful if when querying entries in GraphQL you could get reverse related elements to that entry, which would avoid you having to do multiple GraphQL calls of "get the entry ID, and then run another GraphQL query with relatedTo() because this can quickly add up and become clunky.

Original comment from other thread

Just a thought, and apologies if this was covered in other thoughts above and I misunderstood, would a good syntax for this be something like relatedEntries, relatedAssets etc. which behave like a normal entries / asset loop but with the relatedTo pre-populated with the current entry. So you could do things like this very weird, but hopefully useful example...?

entry(section:"offices",slug:"london"){
   title,
   id,
   ... on offices_offices_entry {
      peopleInThisOffice: relatedEntries(section:"people"){
        title
      }
      facilitiesInThisOffice: relatedEntries(section:"facilities"){
        title
      }
      imagesTaggedInThisOffice: relatedAssets(source:"images"){
        title
      }
   }
}

Originally posted by @andrewfairlie in #5143 (comment)

@brandonkelly brandonkelly added enhancement improvements to existing features graphql ⚙️ features related to the GraphQL API labels Nov 9, 2020
andris-sevcenko added a commit that referenced this issue Nov 27, 2020
@andris-sevcenko
Copy link
Contributor

This has been added for Craft 3.6

@andris-sevcenko
Copy link
Contributor

Well, in its own branch for now.

brandonkelly added a commit that referenced this issue Dec 2, 2020
…ents

Feature/graphql relation arguments

Resolves #7110
Resolves #6911
@brandonkelly
Copy link
Member

Merged now. Note that it’s relatedToEntries, etc., not relatedEntries.

@brandonkelly
Copy link
Member

Craft 3.6 RC2 is out now with these new GraphQL arguments.

@brandonkelly
Copy link
Member

Craft 3.6 has now been officially released ✨

@membla
Copy link

membla commented Feb 22, 2021

Just had a conversation on Discord with @andris-sevcenko on this – the actual issue at hand here is not resolved and even if it may not be feasible to do it in the GraphQL API without changes to the Element Query API or Element itself I think the issue should be reopened because the use case is very valid (and well explained in the original post above).

@brandonkelly brandonkelly added this to the 4.0 milestone Feb 23, 2021
@brandonkelly
Copy link
Member

Whoops, you’re right @membla. Guess we were on a different brainwave. We’re considering how to best address this.

@craftcms craftcms locked and limited conversation to collaborators Jun 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement improvements to existing features graphql ⚙️ features related to the GraphQL API
Projects
None yet
Development

No branches or pull requests

4 participants