GraphQL API query

Avatar

Avatar

alistairp781078

Avatar

alistairp781078

alistairp781078

01-04-2021

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?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

rush_pawan

Avatar

rush_pawan

rush_pawan

01-04-2021

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

Answers (0)