Good morning everyone,
I am using GraphQL to query the Learning Demo space (hotel landing pages etc), and I am trying to query the landing page record along with the “sections” field, which is a one-to-many multi-type array (represented by the sectionsCollection
below)
I’ve got the query to this point so far:
query($preview: Boolean, $locale: String) {
productCollection(preview: $preview, locale: $locale) {
items {
title
seoMetadata {
title
description
}
sectionsCollection(preview: $preview) {
items {
... on Header {
sys {
id
}
name
}
... on CallToAction {
sys {
id
}
name
}
... on Headline {
sys {
id
}
name
}
}
}
}
}
}
{
"preview": false,
"locale": "en-US"
}
This returns the following results (snipped out the irrelevant parts):
"sectionsCollection": {
"items": [
{
"sys": {
"id": "5DlwUXH0c0WAQqYOIYUQou"
},
"name": "TWD Hotels // Header"
},
{},
{},
{
"sys": {
"id": "2wDeIBuu6gQIomKEqYYYKi"
},
"name": "Book Now!"
},
{},
{
"sys": {
"id": "11WW792zpWCg2asWiaYmku"
},
"name": "Rooms and Suites Headline"
},
{},
{},
{},
{
"sys": {
"id": "33tkP252KAmcyok8q8aOEm"
},
"name": "Amenities Headline"
},
{},
{
"sys": {
"id": "22GKqbOFv6oWmugiQsAmgY"
},
"name": "Book Now "
}
]
}
In the query, I can manually specify the inline fragments for each known content type to pull fields from those linked entries, but I can’t seem to figure out how to include the actual content type of those entries in the response so that the application consuming the response knows what it’s actually looking at! It’s just an array of props, and since they can be in any order, I can’t infer the actual content model info from this response.
Any suggestions? Is this a limitation on the API, or am I missing something?