From 3969a947e195ceee450bb2ddc0e258c7c585076a Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 23 Oct 2018 13:51:19 +0200 Subject: [PATCH] fix(gatsby-source-contentful): fix missing linked assets when editing unrelated fields (#9303) --- packages/gatsby-source-contentful/src/normalize.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-source-contentful/src/normalize.js b/packages/gatsby-source-contentful/src/normalize.js index e820a887b37d1..a2dc9cf557b2f 100644 --- a/packages/gatsby-source-contentful/src/normalize.js +++ b/packages/gatsby-source-contentful/src/normalize.js @@ -89,7 +89,16 @@ exports.buildResolvableSet = ({ defaultLocale, }) => { const resolvable = new Set() - existingNodes.forEach(n => resolvable.add(n.id)) + existingNodes.forEach(n => { + if (n.contentful_id) { + // We need to add only root level resolvable (assets and entries) + // derived nodes (markdown or JSON) will be recreated if needed. + // We also need to apply `fixId` as some objects will have ids + // prefixed with `c` and fixIds will recursively apply that + // and resolvable ids need to match that. + resolvable.add(fixId(n.contentful_id)) + } + }) entryList.forEach(entries => { entries.forEach(entry => {