Skip to content

Commit

Permalink
fix(gatsby-source-shopify): Fix empty result error (gatsbyjs#14457)
Browse files Browse the repository at this point in the history
Return an empty array instead of undefined when preparing an empty query result
  • Loading branch information
m-allanson authored and pieh committed May 31, 2019
1 parent 3b70179 commit b34f6d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/gatsby-source-shopify/src/lib.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b34f6d0

Please sign in to comment.