[gatsby-source-contentful] Gatsby unaware of change in Contentful unless delete cache folder #3495
Description
Hi, I'm facing a lot of issues that relate directly to the cache folder.
Description
- If I query a reverse item in one of my query, for example, content type Brand is linked to Category, and I have the following query:
contentfulCategory {
id
brand {
id
}
}
Gatsby would not aware if I publish a new Brand, and the Category page remain the same. If I query for brand directly instead in brand template, the brand page is generated successfully. When I delete the cache folder, and run again, all query and pages work as expected.
-
If I add a new field to content type Category (that Brand link to) and is queried as above, then run gatsby develop, I would get the error
unknown field brand in contentfulCategory
. (query for brand from Category also won't work in Graphiql IDE). Again, manually delete the cache folder and run again solve the problem. -
When I delete a field successfully in Contentful, that field will still be queryable in Gatsby. Delete cache folder also solve this.
Step to reproduce
- Create content type Category and Brand (or any A and B)
- In Brand, add a reference to Category
- Run
gatsby develop
, it compiles successfully - Try each case in the description
- Run
gastby develop
, and see the result - Delete the cache folder and run again, it work correctly.
Environment
Gatsby version: 1.9.145
Node.js version: 6.9.1
Operating System: Windows 6.1.7601
More Info
I'm using gatsby-plugin-react-next
.
Before I found out deleting the cache folder help with the issues. Running gatsby develop
multiple times would occasionally solve the problem.
Edit: It worked because I had some change in gatsby-node.js, which triggers the deletion of cache folder.
Request
Also, it would be great if there's a way to tell Gatsby to completely delete the cache folder on new build in the meantime. I didn't find anything in the documentation. Appreciate if you can show me the direction.