Skip to content

Instantly share code, notes, and snippets.

@LuigiClaudio
Last active December 20, 2020 23:57
Show Gist options
  • Save LuigiClaudio/97ceec8c07c4bfd5a9458b4f5ce53f21 to your computer and use it in GitHub Desktop.
Save LuigiClaudio/97ceec8c07c4bfd5a9458b4f5ce53f21 to your computer and use it in GitHub Desktop.
import { graphql, useStaticQuery } from 'gatsby';
const usePrintfulProducts = () => {
const { allStoreProducts } = useStaticQuery(
graphql`
query usePrintfulProducts {
allStoreProducts(filter: { productId: { ne: null } }) {
nodes {
productId
currency
printfulProduct {
name
id
slug
thumbnail_url
variants {
retail_price
name
style
sync_product_id
id
sku
product {
variant_id
name
}
variantImage {
url
}
}
}
}
}
}
`,
);
const products = allStoreProducts.nodes.map((item) => {
return item;
});
return { products };
};
export default usePrintfulProducts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment