Created
June 18, 2020 21:12
-
-
Save LuigiClaudio/16d120c79e67e62756ad54c6428e2cde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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