query all products for vendors & paths, improve search

This commit is contained in:
cond0r
2021-02-12 09:56:03 +02:00
parent 1450492826
commit 8d801ce5d7
20 changed files with 315 additions and 126 deletions

View File

@@ -0,0 +1,17 @@
const getAllProductVendors = /* GraphQL */ `
query getAllProductVendors($first: Int = 250, $cursor: String) {
products(first: $first, after: $cursor) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
vendor
}
cursor
}
}
}
`
export default getAllProductVendors

View File

@@ -1,6 +1,6 @@
const getAllProductsPathsQuery = /* GraphQL */ `
query getAllProductPaths($first: Int!) {
products(first: $first) {
query getAllProductPaths($first: Int!, $cursor: String) {
products(first: $first, after: $cursor) {
pageInfo {
hasNextPage
hasPreviousPage
@@ -9,6 +9,7 @@ const getAllProductsPathsQuery = /* GraphQL */ `
node {
handle
}
cursor
}
}
}

View File

@@ -1,3 +1,46 @@
export const productsFragment = `
products(
first: $first
sortKey: $sortKey
reverse: $reverse
query: $query
) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
id
title
vendor
handle
description
priceRange {
minVariantPrice {
amount
currencyCode
}
}
images(first: 1) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
originalSrc
altText
width
height
}
}
}
}
}
}
`
const getAllProductsQuery = /* GraphQL */ `
query getAllProducts(
$first: Int = 250
@@ -5,46 +48,7 @@ const getAllProductsQuery = /* GraphQL */ `
$sortKey: ProductSortKeys = RELEVANCE
$reverse: Boolean = false
) {
products(
first: $first
sortKey: $sortKey
reverse: $reverse
query: $query
) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
id
title
vendor
handle
description
priceRange {
minVariantPrice {
amount
currencyCode
}
}
images(first: 1) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
originalSrc
altText
width
height
}
}
}
}
}
}
${productsFragment}
}
`
export default getAllProductsQuery

View File

@@ -0,0 +1,17 @@
import { productsFragment } from './get-all-products-query'
const getCollectionProductsQuery = /* GraphQL */ `
query getProductsFromCollection(
$categoryHandle: String!
$first: Int = 250
$query: String = ""
$sortKey: ProductSortKeys = RELEVANCE
$reverse: Boolean = false
) {
collectionByHandle(handle: $categoryHandle)
{
${productsFragment}
}
}
`
export default getCollectionProductsQuery

View File

@@ -0,0 +1,17 @@
export const getPageQuery = /* GraphQL */ `
query($first: Int!) {
pages(first: $first) {
edges {
node {
id
title
handle
body
bodySummary
url
}
}
}
}
`
export default getPageQuery

View File

@@ -2,6 +2,9 @@ export { default as getSiteCollectionsQuery } from './get-all-collections-query'
export { default as getProductQuery } from './get-all-products-paths-query'
export { default as getAllProductsQuery } from './get-all-products-query'
export { default as getAllProductsPathtsQuery } from './get-all-products-paths-query'
export { default as getAllProductVendors } from './get-all-product-vendors-query'
export { default as getCollectionProductsQuery } from './get-collection-products-query'
export { default as getCheckoutQuery } from './get-checkout-query'
export { default as getAllPagesQuery } from './get-all-pages-query'
export { default as getPageQuery } from './get-page-query'
export { default as getCustomerQuery } from './get-checkout-query'