When using Gatsby as a Live Preview target, Matrix blocks completely disappear. Plain Text fields, however, return draft content as expected. This is only true of draft content, as previewing the current version of an entry works as expected.
I also don't think this has to do with Gatsby, as I can reproduce the behavior querying Craft's GraphQL endpoint directly.
Eager loading behind the scenes, perhaps?
query (fragment makes no difference)
{
home: entries(section: ["homepage"], limit: 1) {
... on homepage_homepage_Entry {
title
metaDescription
pageBlocks {
...PageBlocks
}
}
}
}
fragment PageBlocks on pageBlocks_MatrixField {
... on pageBlocks_hugeIntro_BlockType {
typeHandle
}
... on pageBlocks_serviceSummary_BlockType {
typeHandle
}
... on pageBlocks_statementCta_BlockType {
typeHandle
}
... on pageBlocks_quote_BlockType {
typeHandle
}
}
example.dev/api
response:
{
"data": {
"home": [
{
"title": "Home",
"metaDescription": "Web design and development consultancy that plans, designs and builds custom Craft CMS projects and plugins.",
"pageBlocks": [
{
"typeHandle": "hugeIntro"
},
{
"typeHandle": "serviceSummary"
},
{
"typeHandle": "serviceSummary"
},
{
"typeHandle": "serviceSummary"
},
{
"typeHandle": "statementCta"
},
{
"typeHandle": "quote"
}
]
}
]
}
}
example.dev/api?token=blahblah
response:
{
"data": {
"home": [
{
"title": "Home",
"metaDescription": "Here's a silly draft meta description.",
"pageBlocks": []
}
]
}
}
https://foo.dev/api)https://foo.dev/api?token=••••••)Observe that the query response contains the updated Plain Text field value, but that the Matrix block array is empty.
Having the same issue.
Same issue here as well.
Definitely a side-effect of eager loading all the things.
Just fixed this for the next release.
To get the fix early, change your craftcms/cms requirement in composer.json to:
"require": {
"craftcms/cms": "dev-develop#40d20b6d4ccebc87e7a6dd00f7e0215943db7cf7 as 3.3.9",
"...": "..."
}
Then run composer update.
I can confirm this fixes the problem. Thrilled to use Live Preview for a Gatsby project!
Frickyessss!!!! Thanks @brandonkelly
Most helpful comment
Just fixed this for the next release.
To get the fix early, change your
craftcms/cmsrequirement in composer.json to:Then run
composer update.