Ability to access reverse relations within entry query in GQL #8954
Replies: 9 comments 3 replies
-
This has been added for Craft 3.6 |
Beta Was this translation helpful? Give feedback.
-
Well, in its own branch for now. |
Beta Was this translation helpful? Give feedback.
-
Merged now. Note that it’s |
Beta Was this translation helpful? Give feedback.
-
Craft 3.6 RC2 is out now with these new GraphQL arguments. |
Beta Was this translation helpful? Give feedback.
-
Craft 3.6 has now been officially released ✨ |
Beta Was this translation helpful? Give feedback.
-
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). |
Beta Was this translation helpful? Give feedback.
-
Whoops, you’re right @membla. Guess we were on a different brainwave. We’re considering how to best address this. |
Beta Was this translation helpful? Give feedback.
-
I just wanted to throw some extra support behind this FR. I keep running into places where I do one query to get a URI, just to pass that single URI into a second Having custom directives like the ones noted above would be a big boost to SPA performance and reduce static generated build times, so I'm really hoping to see this get added. Happy to help with testing or coming up with the approach to this. |
Beta Was this translation helpful? Give feedback.
-
Since a milestone 4.0 tag was added back to the original issue in Feb 2021, I was really looking forward to the release of Craft 4 that would address this problem. I've checked out Craft 4 since it's release, but I still can't query the data of reverse relations unfortunately, or I'm missing something. What are the plans with this issue? The GraphQL interface is really lacking functionality here. I already had several cases where I needed to skip functionality because I simply can't get the related data based on the selection in the CMS. Even matching two sets of data is not possible, since no output of reverse relations is available at all. In the end what is the point of creating relations in the CMS if we can't use them in our applications? Looking forward to an update that would address this. Or in case it's already possible I would be happy with a how-to guide. Thanks! |
Beta Was this translation helpful? Give feedback.
-
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 normalentries
/asset
loop but with therelatedTo
pre-populated with the current entry. So you could do things like this very weird, but hopefully useful example...?Originally posted by @andrewfairlie in #5143 (comment)
Beta Was this translation helpful? Give feedback.
All reactions