2

I'm trying to use GraphQL to get my published components as semantic models. I'm using Tridion 9.6 so the models are generated automatically - this works fine.

I am able to retrieve them using a query. For example, to get all components based on the schema Article, I could use this query:

query 
{
  items (
    filter: {
      itemTypes: [COMPONENT],
      publicationIds: [5],
      itemTypes: [ARTICLE]
    }
  ) {
    edges {
      node {
        ... on  Article {
          title
          description
          author
        }
      }
    }
  }
}

This returns a nice, clean list of my 'articles'.

But now I want to retrieve all Article components that are present on the page /article1.html. This page contains 4 components based on the schema Article. The page uses the Data Publishing Page Template and the components are included on the page without any component template (templateless publishing).

Based on the GraphQL schema, I would have thought this query would do the trick:

{
  page(namespaceId: 1, publicationId: 5, url: "/article1.html") {
    title
    components {
      ... on Article {
        title
        description
        author
      }
    }
  }
}

However, although this query is syntactically correct, it does not yield any of the components on the page. It just gives back the page with its title and an empty array of components:

{
  "data": {
    "page": {
      "title": "Article1",
      "components": []
    }
  }
}

Both the page AND the components on it are published - as proven by the fact that I can retrieve these components with a query (the first example in this post).

What am I missing? Why is the components array empty?

1 Answer 1

2

From Paul:

"Hi Quirijn,

This is missing functionality as currently SCM requires all components on a page sit within a page region and you access them through regions on a page. The property you are using should also work and provide access to top-level components or access to all components on a page.

It’s an easy fix so I have created a ticket.

Thanks for finding it. I’ll let you know when it’s available."

1
  • Thanks Paul and Ben. I can confirm that it works if you just put the components inside a region. Looking forward to the fix :)
    – Quirijn
    Commented Sep 23, 2022 at 10:03

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.