gatsby-source-strapi
gatsby-source-strapi copied to clipboard
`content.data` is null when `lastFetched` exists
Hi,
I have a richtext type content
field. Everything was good when I build it for the first time without cache.
But I modified the post
in Strapi and rebuilt it. Then the content.data
of the post
that I modified was null.

version
gatsby ^4.7.2
gatsby-source-strapi 2.0.0-beta.0
Strapi 4.1.0
@ohcmadah did you published your post or did you do it on a draft one?
@soupette The post has already been published. I just saved the post after editing.
@soupette We appear to be having the same issue as @ohcmadah
We are working with,
gatsby 4.10.11
gatsby-source-strapi 2.0.0-beta.0
Strapi 4.1.5
Node 14.16.0
I am not sure if what I am seeing is the expected behaviour or not. The side effects of what I am experiencing are causing issues with Gatsby Cloud Builds and Previews.
My test case involved a simple basic page content type with three fields, Title, Body and Image. I added two test pages one published, and the other in draft mode (never been published).
In Gatsby config I'm using the publicationState query params to switch between live and preview modes.
queryParams: {
publicationState: process.env.GATSBY_IS_PREVIEW === 'true' ? 'preview' : 'live',
}
My query is as follows,
query MyQuery {
allStrapiBasicPage {
edges {
node {
id
Title
Body {
data {
Body
}
}
publishedAt
Image {
url
}
}
}
}
}
Querying with publicationState set to 'live'. I'm getting all field values for just the page that is published. This is what I would expect.
{
"data": {
"allStrapiBasicPage": {
"edges": [
{
"node": {
"id": "16e95dfd-b3cb-56ba-9d2e-039229442088",
"Title": "Page 1",
"Body": {
"data": {
"Body": "This page has been published."
}
},
"publishedAt": "2022-03-18T15:59:38.312Z",
"Image": {
"url": "/uploads/ehteshamul_haque_adit_0_Dg108bwghs_unsplash_b61aadce10.jpg"
}
}
}
]
}
},
"extensions": {
"enableRefresh": "true"
}
}
Querying with publicationState set to 'preview'. I'm getting both the draft and published page in the results. This all seems normal to me at this stage.
{
"data": {
"allStrapiBasicPage": {
"edges": [
{
"node": {
"id": "16e95dfd-b3cb-56ba-9d2e-039229442088",
"Title": "Page 1",
"Body": {
"data": {
"Body": "This page has been published."
}
},
"publishedAt": "2022-03-18T15:59:38.312Z",
"Image": {
"url": "/uploads/ehteshamul_haque_adit_0_Dg108bwghs_unsplash_b61aadce10.jpg"
}
}
},
{
"node": {
"id": "b05334a3-ebfc-54b5-9b90-7ab7d0b5dae9",
"Title": "Page 2",
"Body": {
"data": {
"Body": "This page is unpublished so therefore in Draft mode."
}
},
"publishedAt": null,
"Image": {
"url": "/uploads/ehteshamul_haque_adit_0_Dg108bwghs_unsplash_b61aadce10.jpg"
}
}
}
]
}
},
"extensions": {
"enableRefresh": "true"
}
}
So now I go into Strapi and edit any field in Page 1 (the published content) and hit save. Refreshing Data in GraphiQL yields a different result which I do not full understand.
The field values for the published page (page 1) appear fine apart from the rich text 'Body' field which is now null. This does not seem like the expected behaviour to me.
{
"data": {
"allStrapiBasicPage": {
"edges": [
{
"node": {
"id": "b05334a3-ebfc-54b5-9b90-7ab7d0b5dae9",
"Title": "Page 2",
"Body": {
"data": {
"Body": "This page is unpublished so therefore in Draft mode."
}
},
"publishedAt": null,
"Image": {
"url": "/uploads/ehteshamul_haque_adit_0_Dg108bwghs_unsplash_b61aadce10.jpg"
}
}
},
{
"node": {
"id": "16e95dfd-b3cb-56ba-9d2e-039229442088",
"Title": "Page 1",
"Body": {
"data": null
},
"publishedAt": "2022-03-18T15:59:38.312Z",
"Image": {
"url": "/uploads/ehteshamul_haque_adit_0_Dg108bwghs_unsplash_b61aadce10.jpg"
}
}
}
]
}
},
"extensions": {
"enableRefresh": "true"
}
}
The only way to get the value of Body back is to do a clean rebuild with Gatsby.
Can confirm this. Having the same issues.
- gatsby 4.13
- gatsby-source-strapi 2.0.0
- gatsby-plugin-gatsby-cloud 4.14.0-next.3
- Strapi 4.1.9
- Node 14.16.0
I have a heroku strapi-deploy and gatsby through their cloud. I'd like to add the following observation;
My posts have various fields (richtexts, shorttexts, number arrays and so on) and components (dynamic repeatable zone) and the publishing process to first preview your content changes through the gatsby-cloud plugin work fine. Even if I do incremental cloud builds without cache it works. I can change images, rearrange orders and so on. All none RichText fields from strapi are working fine basically, I tested them all. Builds and previews are complete and fast and built without cache.
But as soon as I change any RichText content, the preview and build fails. Only after a fresh cache build it'll show the content. So i think it only has to do with RichText fields (data.childMarkdownRemark.html) and returning null after updating and therefore break the build since gatsby-source-strapi works as intended here I guess.
Any ideas? Did someone find a way to get around this?
... on STRAPI__COMPONENT_SHARED_RICH_TEXT {
richTextBody: body {
__typename
data {
id
childMarkdownRemark {
html
}
}
}
}
We have the same issue! Is there any workaround for this? It is very urgent, because I do not know any way for my customers to get their content online without deleting the cache and bearing very long build time.
I fixed all my problems with this source plugin: https://github.com/relate-app/gatsby-source-strapi It can do incremental builds and previews (which was important to me).
Has anyone found a solution for this? I'm having the same problem
@joanargarrido see #321
Can confirm I have the same issue currently