Using Gatsby & Gatsby-Contentful everything works as expect. On Gatsby Develop or Gatsby Build graphql queries are run and content is pulled from Contentful correctly.
When there is a change in and Contentful content and a subsequent Gatsby Develop or Gatsby Build is run the changed content is detected but results in null values for some resources. For this project it's an image.
I have solved this by adding rm -r .cache to my gatsby develop script. But feel like there has to be a better solution than blowing away the cache every time.
On new Contentful post / Success:
```New Post Success:
$ gatsby develop
success open and validate gatsby-config — 0.008 s
success load plugins — 0.199 s
success onPreInit — 0.804 s
success delete html and css files from previous builds — 0.053 s
success initialize cache — 0.006 s
success copy gatsby files — 0.061 s
success onPreBootstrap — 0.007 s
⠄ source and transform nodesStarting to fetch data from Contentful
Fetching default locale
⠁ source and transform nodesdefault locale is : en-US
⠐ source and transform nodescontentTypes fetched 1
Updated entries 1
Deleted entries 0
Updated assets 0
Deleted assets 0
Fetch Contentful data: 747.359ms
success source and transform nodes — 0.898 s
success building schema — 0.326 s
success createPages — 0.050 s
success createPagesStatefully — 0.036 s
success onPreExtractQueries — 0.011 s
success update schema — 0.202 s
success extract queries from components — 0.201 s
success run graphql queries — 0.591 s — 13/13 22.08 queries/second
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s
On change of Contentful content / Fail:
$ gatsby develop
success open and validate gatsby-config — 0.010 s
success load plugins — 0.207 s
success onPreInit — 0.860 s
success delete html and css files from previous builds — 0.053 s
success initialize cache — 0.007 s
success copy gatsby files — 0.053 s
success onPreBootstrap — 0.008 s
⠄ source and transform nodesStarting to fetch data from Contentful
Fetching default locale
⠁ source and transform nodesdefault locale is : en-US
⠂ source and transform nodescontentTypes fetched 1
Updated entries 1
Deleted entries 0
Updated assets 0
Deleted assets 0
Fetch Contentful data: 946.949ms
success source and transform nodes — 1.125 s
success building schema — 0.330 s
success createPages — 0.053 s
success createPagesStatefully — 0.038 s
success onPreExtractQueries — 0.009 s
success update schema — 0.186 s
success extract queries from components — 0.213 s
success run graphql queries — 0.542 s — 13/13 24.09 queries/second
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s
info bootstrap finished - 6.657 s
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
WAIT Compiling... 4:53:36 PM
ℹ 「wdm」: Compiling...
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/src/pages/posts.js
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/.cache/gatsby-browser-entry.js
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/node_modules/react-dom/cjs/react-dom.development.js
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/node_modules/react/cjs/react.development.js
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/.cache/json-store.js
ℹ 「wdm」: wait until bundle finished: /posts/clients/master/node_modules/mitt/dist/mitt.es.js
graphiql showing error:
{
"data": {
"allContentfulBlogPost": {
"edges": [
{
"node": {
"mainImage": null
}
},
{
"node": {
"mainImage": {
"title": "Beans"
}
}
}
]
}
}
}
```
Connect to Gatsby to Contentful. Create a post. Run locally. Change the contents of the post. Run locally.
This is a private repo but happy to share if someone has protips on how to redact it for public eyes.
Gatsby should pull Contentful post and recognize changes
Returns and error for a null value
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.2.0 - ~/.nvm/versions/node/v10.9.0/bin/npm
Browsers:
Chrome: 69.0.3497.100
Firefox: 61.0.2
Safari: 12.0
npmPackages:
gatsby: ^2.0.19 => 2.0.19
gatsby-image: ^2.0.13 => 2.0.13
gatsby-link: ^2.0.4 => 2.0.4
gatsby-plugin-google-analytics: ^2.0.6 => 2.0.6
gatsby-plugin-manifest: ^2.0.2 => 2.0.4
gatsby-plugin-offline: ^2.0.5 => 2.0.5
gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0
gatsby-plugin-remove-trailing-slashes: ^2.0.3 => 2.0.3
gatsby-plugin-sass: ^2.0.1 => 2.0.1
gatsby-plugin-sharp: ^2.0.6 => 2.0.6
gatsby-remark-copy-linked-files: ^2.0.5 => 2.0.5
gatsby-remark-images: ^2.0.3 => 2.0.3
gatsby-source-contentful: ^2.0.2 => 2.0.2
gatsby-source-filesystem: ^2.0.2 => 2.0.2
gatsby-transformer-remark: ^2.1.6 => 2.1.6
gatsby-transformer-sharp: ^2.1.3 => 2.1.3
This is causing me many headaches too! Is this likely to be fixed soon??
I've been experiencing problems relating to this issue. A fix would be much appreciated
I have the same problem..
When there is a change in and Contentful content and a subsequent Gatsby Develop or Gatsby Build is run the changed content is detected but results in
nullvalues for some resources. For this project it's an image.
Is null happening for resource that got changed or for "unrelated" data?
We probably need more information here
@pieh for my project, any data field changed that is not related to the image eg: title, heading, etc results in a null value for mainImage.
If I change fields related to mainImage title, heading, etc but not the image itself, everything works as expected.
If I change/modify the image itself, mainImage is a again anull value.
Any additional information - like do you use locales or environments would be really helpful for us to debug this problem
/cc @Khaledgarbaya
Ok, I can definitely reproduce that
oh, I got this - will have PR with fix soon
@pieh Rad! Excited to see what you came up with!
Great to hear this is being fixed thanks guys!
Fix was published in [email protected] please update and let us know if it fixes the issue or there are situation where it still happen
@pieh Thanks! Everything is working as expected for me with [email protected] & gatsby: "^2.0.19
Was having issue were only the Image added last was showing up. Updating to @2.0.5 fixed it. Thanks @pieh !
@pieh I have the same issue with [email protected] for each content I add in Contentful. I need to remove cache each time...
@ludovicmnji as the comment say before this is fixed in [email protected] & gatsby: "^2.0.19 please make sure to install the latest version
@Khaledgarbaya I confirm you I reproduce the issue with [email protected] and [email protected]. I just installed the Gatsby starter and write some lines of code to test the integration with Contentful, nothing more.
@ludovicmnji you missed the [email protected]
@Khaledgarbaya Sorry I misunderstood your previous message 😥
I tested with [email protected] and it works ! So the problem is probably came back. I can test with other versions if you want.
Most helpful comment
Fix was published in
[email protected]please update and let us know if it fixes the issue or there are situation where it still happen