From 452b844b10c2c103cdbc753d2d431c43af4ab3ac Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Thu, 7 Jan 2021 14:30:39 +0100 Subject: [PATCH] fix(gatsby): rewrite a spread that would break at scale --- packages/gatsby/src/schema/node-model.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gatsby/src/schema/node-model.js b/packages/gatsby/src/schema/node-model.js index 3e2d18968abbb..621b4e4a718e5 100644 --- a/packages/gatsby/src/schema/node-model.js +++ b/packages/gatsby/src/schema/node-model.js @@ -199,10 +199,10 @@ class LocalNodeModel { result = getNodes() } else { const nodeTypeNames = toNodeTypeNames(this.schema, type) - const nodes = nodeTypeNames.reduce((acc, typeName) => { - acc.push(...getNodesByType(typeName)) - return acc - }, []) + const nodesByType = nodeTypeNames.map(typeName => + getNodesByType(typeName) + ) + const nodes = [].concat(...nodesByType) result = nodes.filter(Boolean) }