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?