Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

GraphQL API query

alistairp781078
Level 4
Level 4

I've been following the GraphQL API in AEM tutorial here: https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/g...

 

On the page above it demonstrates how to add a fragment reference for a contributor to an adventure. It then shows how to construct a query to find the contributor(s) for a particular adventure:

 

{
  adventureByPath(_path:"/content/dam/wknd/en/adventures/bali-surf-camp/bali-surf-camp") {
     item {
       _path
       adventureTitle
       adventureContributor {
         fullName
         ...
      }
    }
  }
 }
}

 

Is it possible to write a reversal of this query where you can find all of the adventures that a contributor has contributed to?

1 Accepted Solution
Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor

Hello,

 

Just want to add my thoughts. 

 

I would look at it from Model and Model associations. Now in this case the model is adventure which has association of contributor and model instances (fragments) are created for adventure.

 

So, looking at this scenario the query should be finding out all adventure associated to specific contributor or set of contributor under adventure path (because otherwise query or filtering will be cumbersome), until unless you have other way model creation where contributor has association of adventures and created as model instances (fragments) in filter.

 

(i hope, was able to clear it)

 

refer very good video around same: https://adapt.to/2020/en/schedule/graphql-services-in-the-aem-world.html

View solution in original post

2 Replies
Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor

Hello,

 

Just want to add my thoughts. 

 

I would look at it from Model and Model associations. Now in this case the model is adventure which has association of contributor and model instances (fragments) are created for adventure.

 

So, looking at this scenario the query should be finding out all adventure associated to specific contributor or set of contributor under adventure path (because otherwise query or filtering will be cumbersome), until unless you have other way model creation where contributor has association of adventures and created as model instances (fragments) in filter.

 

(i hope, was able to clear it)

 

refer very good video around same: https://adapt.to/2020/en/schedule/graphql-services-in-the-aem-world.html

View solution in original post

alistairp781078
Level 4
Level 4

Thanks for your thoughts and the link to the video, very helpful! I've had another think and was able to get this to work by applying a filter to the nested adventureContributor property.

 

Something like:

 

{
      adventureList(filter: {
          adventureContributor: {
            fullName: {
                _expressions: [
                    {
                        value: "Jacob Wester"
                        _operator: EQUALS
                    }
                ]
            }
          }
      }) {
          items {
            _path
            adventureContributor {
                _path
                fullName
            }
          }
      }
}