From 7fc3674ce86b1f1b488a39fac8f7eb080f2879d0 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 13 Feb 2018 23:42:59 +0100 Subject: [PATCH] Fix tracking nodes with filtering/running sift. Before we filter nodes we create copies of nodes with appended fields added by plugins (by setFieldsOnGraphQLNodeType) if they are filtered on. These copies weren't tracked. --- packages/gatsby/src/redux/index.js | 1 + packages/gatsby/src/schema/run-sift.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/gatsby/src/redux/index.js b/packages/gatsby/src/redux/index.js index 036ac2c19f6af..64d6fce0d09ce 100644 --- a/packages/gatsby/src/redux/index.js +++ b/packages/gatsby/src/redux/index.js @@ -48,6 +48,7 @@ const trackInlineObjectsInRootNode = node => { } addRootNodeToInlineObject(v, node.id) }) + return node } exports.trackInlineObjectsInRootNode = trackInlineObjectsInRootNode diff --git a/packages/gatsby/src/schema/run-sift.js b/packages/gatsby/src/schema/run-sift.js index 9b3119630975a..b6f498913cc9d 100644 --- a/packages/gatsby/src/schema/run-sift.js +++ b/packages/gatsby/src/schema/run-sift.js @@ -5,6 +5,7 @@ const { connectionFromArray } = require(`graphql-skip-limit`) const { createPageDependency } = require(`../redux/actions/add-page-dependency`) const prepareRegex = require(`./prepare-regex`) const Promise = require(`bluebird`) +const { trackInlineObjectsInRootNode } = require(`../redux`) function awaitSiftField(fields, node, k) { const field = fields[k] @@ -109,6 +110,7 @@ module.exports = ({ return Promise.all( nodes.map(node => resolveRecursive(node, fieldsToSift, type.getFields())) ).then(myNodes => { + myNodes = myNodes.map(trackInlineObjectsInRootNode) if (!connection) { const index = _.isEmpty(siftArgs) ? 0