Skip to content

Commit

Permalink
fix: shopify app throw an error if collection or product is missing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalmishra090 authored and ryunsong-contentful committed Jul 10, 2023
1 parent 968d969 commit efc085d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/shopify/src/skuResolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export const fetchCollectionPreviews = async (skus, config) => {
const validIds = filterAndDecodeValidIds(skus, 'Collection');

const response = await paginateGraphQLRequest(config, validIds, collectionQuery);
const collections = response.map((res) => convertCollectionToBase64(res));
const collections = response.map((res) => res && convertCollectionToBase64(res));

return validIds.map((validId) => {
const collection = collections.find(
(collection) => collection.id === convertStringToBase64(validId)
(collection) => collection?.id === convertStringToBase64(validId)
);
return collection
? collectionDataTransformer(collection, config.apiEndpoint)
Expand Down Expand Up @@ -133,7 +133,7 @@ export const fetchProductPreviews = async (skus, config) => {
}

const response = (await Promise.all(requests)).flat();
const products = response.map((res) => convertProductToBase64(res));
const products = response.map((res) => res && convertProductToBase64(res));

return validIds.map((validId) => {
const product = products.find((product) => product?.id === convertStringToBase64(validId));
Expand Down

0 comments on commit efc085d

Please sign in to comment.