From b34f6d04f1b2fcc4017314297f55de9fadb74bc9 Mon Sep 17 00:00:00 2001 From: Mike Allanson Date: Fri, 31 May 2019 13:00:28 +0100 Subject: [PATCH] fix(gatsby-source-shopify): Fix empty result error (#14457) Return an empty array instead of undefined when preparing an empty query result --- packages/gatsby-source-shopify/src/lib.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-source-shopify/src/lib.js b/packages/gatsby-source-shopify/src/lib.js index 37e5d2422d005..0438eb3280ae4 100644 --- a/packages/gatsby-source-shopify/src/lib.js +++ b/packages/gatsby-source-shopify/src/lib.js @@ -1,6 +1,6 @@ import { GraphQLClient } from "graphql-request" import prettyjson from "prettyjson" -import { get, last } from "lodash/fp" +import { get, getOr, last } from "lodash/fp" /** * Create a Shopify Storefront GraphQL client for the provided name and token. @@ -43,8 +43,7 @@ export const queryAll = async ( aggregatedResponse = null ) => { const data = await queryOnce(client, query, first, after) - - const edges = get([...path, `edges`], data) + const edges = getOr([], [...path, `edges`], data) const nodes = edges.map(edge => edge.node) aggregatedResponse = aggregatedResponse