Skip to content

Instantly share code, notes, and snippets.

@LuigiClaudio
Created June 18, 2020 21:12
Show Gist options
  • Save LuigiClaudio/16d120c79e67e62756ad54c6428e2cde to your computer and use it in GitHub Desktop.
Save LuigiClaudio/16d120c79e67e62756ad54c6428e2cde to your computer and use it in GitHub Desktop.
import { graphql, useStaticQuery } from 'gatsby';
const usePrintfulProductsInCms = () => {
const { allStoreProducts } = useStaticQuery(
graphql`
query usePrintfulProductsInCms {
allStoreProducts {
nodes {
productId
currency
printful {
name
slug
thumbnail_url
external_id
variants {
currency
retail_price
name
variantStyle
id
external_id
parentProduct {
id
external_id
}
product {
name
product_id
variant_id
}
variantImage {
url
}
catalogVariant {
size
color
}
catalogProduct {
description
model
}
}
}
cms {
title
isActive
productId
subtitle
discount
shortDescription
description
group
categoryList {
category
}
}
cloudinary {
tags
secure_url
}
}
}
}
`,
);
const products = allStoreProducts.nodes.map((item) => item).filter((i) => i.cms);
return { products };
};
export default usePrintfulProductsInCms;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment