orgajs icon indicating copy to clipboard operation
orgajs copied to clipboard

Can't query for posts after change without invalidating cache

Open Qkessler opened this issue 4 years ago • 0 comments

When I update or change any data inside the content folder, there is a need to invalidate the Gatsby cache (either by removing the .cache folder or by running 'gatsby clean') in order to be able to query the blog posts. If you don't do so, the build command is received with:

There was an error in your GraphQL query:

Cannot read property 'indexOf' of undefined

8 |
   9 | query PostById($id: String!, $maxWidth: Int) {
  10 |   orgPost(id: {eq: $id}) {
  11 |     title
  12 |     category
  13 |     excerpt
  14 |     date(formatString: "MMMM DD, YYYY")
  15 |     tags
  16 |     html
  17 |     slug
> 18 |     timeToRead
     |     ^
  19 |     wordCount
  20 |     image {
  21 |       childImageSharp {
  22 |         fluid(maxWidth: $maxWidth) {
  23 |           ...GatsbyImageSharpFluid
  24 |           src
  25 |         }
  26 |       }
  27 |     }
  28 |   }

File path: /usr/src/app/www/node_modules/gatsby-theme-orga/src/templates/post-query.js`

This is the output by the Gatsby Cloud build. As I haven't still found a way to invalidate Gatsby Cloud's cache between builds, there is no possible way to rebuild the site after any changes on the blog posts.

Is this behaviour expected or at least noted? I would love some info on the topic and a way to bypass or fix the problem would be greatly appreciated. Take care, Enrique.

Qkessler avatar Apr 22 '21 11:04 Qkessler