1

I want to create a nested ul li list based on a list of publications --> submaps --> submaps... and so on; using graphql query. I am able to achive following:

  1. list of publications
  2. 1st level of submaps based on rootmap id

I am looking for the:

  1. I need to get a list of submaps based on 2nd-level sub-maps. i have submap id[e.g: "t1-k74"] of the 1st level and publication id.

1 Answer 1

3

Understanding Tridion Docs Table of Contents (TOC) in DXD

Tridion Docs TOC is stored in DXD as categories and keywords, representing nested levels. In DXD 11.1, there is no dedicated Tridion Docs-specific TOC GraphiQL API. However, you can retrieve the TOC using the following GraphiQL APIs:

  • categories
  • keyword

Additionally, two GraphiQL APIs become available after installing the DXA custom model extension from DXD 11.1 installation media (udp-content-dxa-extension-assembly-11.1.0-1061-core.zip):

  • sitemapStructure
  • sitemapSubtree

Refer to the Tridion Docs DDWebapp module API controller for the GraphiQL TocProvider.

Example GraphiQL Queries:

  • Get TOC with categories Graphiql API
query GetCategories($namespaceId: Int!, $publicationId: Int!)
{
  categories(namespaceId: $namespaceId, publicationId: $publicationId) {
    edges {
      node {
        ...KeywordFields
        children {
          edges {
            node {
              ...KeywordFields
              children {
                 edges {
                    node {
                      ...KeywordFields   
                      children {
                       edges {
                          node {
                            ...KeywordFields  
                          }
                       }
                     }
                    }
                 }
               }
            }
          }
        }
      }
    }
  }
}

fragment KeywordFields on Keyword
{
  id,
  itemId,
  title,
  itemType
  taxonomyType
}

  • Get TOC Sitemap Subtree No Recurse with DXA model extension
{
    sitemapSubtree(namespaceId: 2, publicationId: 12343, taxonomyNodeId: "t1") 
    {
        ...TaxonomyItemFields    
    }
}

fragment TaxonomyItemFields on TaxonomySitemapItem 
{
    id    
    title
    originalTitle
    url
    type
    visible
    description
    key
    abstract
    hasChildNodes
    classifiedItemsCount
} 

  • Get TOC Parent and Child level with DXA model extension
{
    sitemapSubtree(namespaceId: 2, publicationId:12343 , taxonomyNodeId: "t1-k2") 
    {
        ...TaxonomyItemFields    
        ...RecurseItems
    }
}
fragment TaxonomyItemFields on TaxonomySitemapItem 
{
    id    
    title
    originalTitle
    url
    type
    visible
    description
    key
    abstract
    hasChildNodes
    classifiedItemsCount
} 
fragment RecurseItems on TaxonomySitemapItem 
{  
    items 
    {  
        ...on TaxonomySitemapItem {...TaxonomyItemFields}
        ...on PageSitemapItem {...TaxonomyPageFields}
    }
}
fragment TaxonomyPageFields on PageSitemapItem 
{    
    id
    title
    originalTitle
    url
    type
    publishedDate
    visible  
}

In summary, these GraphiQL queries and examples serve as a guide to retrieve nested submaps from Tridion Docs TOC in DXD. Be mindful of version-specific considerations.

1
  • Great examples! I like the use of query fragments at the end of the examples as well as inline queries (with the "...on" syntax). These are probably already familiar to those who've used GraphQL but might be "new" to those first using the query language. :-) Commented Jan 4 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.