Good day I am having an issue with queuing against a group that contains a relationship.
I have tried the following:
const collections = await api.getAllByType('collection', {
graphQuery: ` {
collection {
title
description
products {
products_product {
uid
title
product_image
modal_image
}
}
}
}`
})
Also tried using
await api.getAllByType('collection', {
fetchLinks: ['product.product_image', 'product.title']
})
Both of these queries compile and work but in the end the data inside the relationship returns undefined.
[0] TypeError: /Users/johngrange/Projects/portfolio/views/pages/collections.pug:13
[0] 11| each collection in collections
[0] 12| each product in collection.data.products
[0] > 13| h1= product.data.title
[0] Cannot read property 'title' of undefined
It also fails in code if I try the following:
collections[0].data.products.forEach(product => {
console.log(product)
console.log(product.title)
})
[0] products_product: {
[0] id: 'Y7uIehEAACEAJtPO',
[0] type: 'product',
[0] tags: [],
[0] lang: 'en-us',
[0] slug: 'silver-necklace',
[0] first_publication_date: '2023-01-09T03:22:41+0000',
[0] last_publication_date: '2023-01-15T04:47:13+0000',
[0] uid: 'silver_necklace',
[0] data: {
[0] uid: 'silver_necklace',
[0] title: 'Silver Necklace',
[0] product_image: [Object],
[0] modal_image: [Object]
[0] },
[0] link_type: 'Document',
[0] isBroken: false
[0] }
[0] }
[0] undefined // This should be the title, and even though it shows above clearly it is not accessiable
I have also tried:
console.log(product.data.title)
[0] (node:63478) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'title' of undefined
[0] at /Users/johngrange/Projects/portfolio/app.js:123:30
[0] at Array.forEach (<anonymous>)
[0] at /Users/johngrange/Projects/portfolio/app.js:121:32
[0] at processTicksAndRejections (internal/process/task_queues.js:95:5)
In addition , it seems my GraphQL explorer does not work, when I try to query I only get back "", and the documentation tab is empty.