saleor: integrate collections

This commit is contained in:
Zaiste 2021-05-13 13:22:57 +02:00
parent 9ca6c38755
commit f5ec8e17a4
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
3 changed files with 8 additions and 14 deletions

View File

@ -45,7 +45,7 @@ export const handler: SWRHook<
let edges let edges
if (categoryId) { if (categoryId) {
edges = data.node?.products?.edges ?? [] edges = data.collection?.products?.edges ?? []
// FIXME @zaiste, no `vendor` in Saleor // FIXME @zaiste, no `vendor` in Saleor
// if (brandId) { // if (brandId) {
// edges = edges.filter( // edges = edges.filter(

View File

@ -1,5 +1,5 @@
import { SaleorConfig } from '../api' import { SaleorConfig } from '../api'
import { Collection, CollectionCountableEdge } from '../schema' import { CollectionCountableEdge } from '../schema'
import { getSiteCollectionsQuery } from './queries/' import { getSiteCollectionsQuery } from './queries/'
export type Category = { export type Category = {

View File

@ -3,21 +3,15 @@ import { productConnection } from './get-all-products-query'
export const getCollectionProductsQuery = /* GraphQL */ ` export const getCollectionProductsQuery = /* GraphQL */ `
query getProductsFromCollection( query getProductsFromCollection(
$categoryId: ID! $categoryId: ID!
$first: Int = 250 $first: Int = 100
$sortKey: ProductCollectionSortKeys = RELEVANCE $channel: String = "default-channel"
$reverse: Boolean = false
) { ) {
node(id: $categoryId) { collection(id: $categoryId, channel: $channel) {
id id
... on Collection { products(first: $first) {
products( ...productConnection
first: $first
sortKey: $sortKey
reverse: $reverse
) {
${productConnection}
}
} }
} }
} }
${productConnection}
` `