gatsby: Gatsby-Contentful change of Contentful content produces null values / .cache error

Description

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:

$ 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"
            }
          }
        }
      ]
    }
  }
}

Steps to reproduce

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.

Expected result

Gatsby should pull Contentful post and recognize changes

Actual result

Returns and error for a null value

Environment

System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel® Core™ 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Fix was published in gatsby-source-contentful@2.0.5 please update and let us know if it fixes the issue or there are situation where it still happen

I’ve been experiencing problems relating to this issue. A fix would be much appreciated

This is causing me many headaches too! Is this likely to be fixed soon??

I have the same problem…