Last active
November 16, 2023 07:07
-
-
Save jorgemasta/fc5b29c59bd66d26ce3d28c1b71130b3 to your computer and use it in GitHub Desktop.
Revisions
-
jorgemasta revised this gist
Feb 5, 2021 . No changes.There are no files selected for viewing
-
jorgemasta created this gist
Feb 5, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,113 @@ import { productPrices, multipleChoiceOptionFragment } from '@framework/api/fragments/product'; const productInfoFragment = /* GraphQL */ ` fragment productInfo on Product { entityId name path brand { entityId } description prices { ...productPrices } images { edges { node { urlOriginal altText isDefault } } } variants { edges { node { entityId defaultImage { urlOriginal altText isDefault } } } } productOptions { edges { node { __typename entityId displayName ...multipleChoiceOption } } } relatedProducts { edges { node { name } } } localeMeta: metafields(namespace: $locale, keys: ["name", "description"]) @include(if: $hasLocale) { edges { node { key value } } } } ${productPrices} ${multipleChoiceOptionFragment} ` const productConnectionFragment = /* GraphQL */ ` fragment productConnnection on ProductConnection { pageInfo { startCursor endCursor } edges { cursor node { ...productInfo } } } ${productInfoFragment} ` export const customGetAllProductsQuery = /* GraphQL */ ` query getAllProducts( $hasLocale: Boolean = false $locale: String = "null" $entityIds: [Int!] $first: Int = 10 $products: Boolean = false $featuredProducts: Boolean = false $bestSellingProducts: Boolean = false $newestProducts: Boolean = false ) { site { products(first: $first, entityIds: $entityIds) @include(if: $products) { ...productConnnection } featuredProducts(first: $first) @include(if: $featuredProducts) { ...productConnnection } bestSellingProducts(first: $first) @include(if: $bestSellingProducts) { ...productConnnection } newestProducts(first: $first) @include(if: $newestProducts) { ...productConnnection } } } ${productConnectionFragment} `