From ae946c38d980ff188b36e8d8a19f4340cb5ed5af Mon Sep 17 00:00:00 2001 From: Benjamin Abel Date: Sun, 1 Jul 2018 21:52:34 +0200 Subject: [PATCH] Add gatsby v2 as peer dependencie --- package.json | 3 +++ src/gatsby-node.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index e0630a6..40f133b 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,8 @@ }, "dependencies": { "elasticlunr": "^0.9.5" + }, + "peerDependencies": { + "gatsby": ">2.0.0-alpha" } } diff --git a/src/gatsby-node.js b/src/gatsby-node.js index 733d693..25bfaa9 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -50,6 +50,7 @@ const createOrGetIndex = async (node, cache, getNode, server, { for (const pageId of node.pages) { const pageNode = getNode(pageId); + const fieldResolvers = resolvers[pageNode.internal.type]; if (fieldResolvers) { const doc = { @@ -99,6 +100,7 @@ exports.sourceNodes = async ({ getNodes, actions }) => { exports.onCreateNode = ({node, actions, getNode}, { resolvers, }) => { + if (Object.keys(resolvers).indexOf(node.internal.type) === -1) { return; }