mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Added basis setup and type generation for the products queries
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
const getSiteCollectionsQuery = /* GraphQL */ `
|
||||
query getSiteCollections($first: Int!) {
|
||||
collections(first: $first) {
|
||||
query getSiteCollections($first: Int!, $channel: String = "default-channel") {
|
||||
collections(first: $first, channel: $channel) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
handle
|
||||
name
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
export const getAllPagesQuery = /* GraphQL */ `
|
||||
query getAllPages($first: Int = 250) {
|
||||
query getAllPages($first: Int = 100) {
|
||||
pages(first: $first) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
handle
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,17 @@
|
||||
const getAllProductsPathsQuery = /* GraphQL */ `
|
||||
query getAllProductPaths($first: Int = 250, $cursor: String) {
|
||||
products(first: $first, after: $cursor) {
|
||||
query getAllProductPaths(
|
||||
$first: Int = 100
|
||||
$cursor: String
|
||||
$channel: String = "default-channel"
|
||||
) {
|
||||
products(first: $first, after: $cursor, channel: $channel) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
handle
|
||||
slug
|
||||
}
|
||||
cursor
|
||||
}
|
||||
|
@@ -1,57 +1,42 @@
|
||||
export const productConnection = `
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
vendor
|
||||
handle
|
||||
description
|
||||
priceRange {
|
||||
minVariantPrice {
|
||||
amount
|
||||
currencyCode
|
||||
}
|
||||
export const productConnection = /* GraphQL */ `
|
||||
fragment productConnnection on ProductCountableConnection {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
images(first: 1) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
originalSrc
|
||||
altText
|
||||
width
|
||||
height
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
description
|
||||
slug
|
||||
pricing {
|
||||
priceRange {
|
||||
start {
|
||||
net {
|
||||
amount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
media {
|
||||
url
|
||||
alt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
export const productsFragment = `
|
||||
products(
|
||||
first: $first
|
||||
sortKey: $sortKey
|
||||
reverse: $reverse
|
||||
query: $query
|
||||
) {
|
||||
${productConnection}
|
||||
}
|
||||
`
|
||||
|
||||
const getAllProductsQuery = /* GraphQL */ `
|
||||
query getAllProducts(
|
||||
$first: Int = 250
|
||||
$query: String = ""
|
||||
$sortKey: ProductSortKeys = RELEVANCE
|
||||
$reverse: Boolean = false
|
||||
$first: Int = 100
|
||||
$channel: String = "default-channel"
|
||||
) {
|
||||
${productsFragment}
|
||||
products(first: $first, channel: $channel) {
|
||||
...productConnnection
|
||||
}
|
||||
}
|
||||
${productConnection}
|
||||
`
|
||||
export default getAllProductsQuery
|
||||
|
@@ -1,66 +1,34 @@
|
||||
const getProductQuery = /* GraphQL */ `
|
||||
query getProductBySlug($slug: String!) {
|
||||
productByHandle(handle: $slug) {
|
||||
query getProductBySlug($slug: String!, $channel: String = "default-channel") {
|
||||
product(slug: $slug, channel: $channel) {
|
||||
id
|
||||
handle
|
||||
title
|
||||
productType
|
||||
vendor
|
||||
slug
|
||||
name
|
||||
description
|
||||
descriptionHtml
|
||||
options {
|
||||
pricing {
|
||||
priceRange {
|
||||
start {
|
||||
net {
|
||||
amount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
variants {
|
||||
id
|
||||
name
|
||||
values
|
||||
}
|
||||
priceRange {
|
||||
maxVariantPrice {
|
||||
amount
|
||||
currencyCode
|
||||
}
|
||||
minVariantPrice {
|
||||
amount
|
||||
currencyCode
|
||||
}
|
||||
}
|
||||
variants(first: 250) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
sku
|
||||
selectedOptions {
|
||||
name
|
||||
value
|
||||
}
|
||||
priceV2 {
|
||||
pricing {
|
||||
price {
|
||||
net {
|
||||
amount
|
||||
currencyCode
|
||||
}
|
||||
compareAtPriceV2 {
|
||||
amount
|
||||
currencyCode
|
||||
currency
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
images(first: 250) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
originalSrc
|
||||
altText
|
||||
width
|
||||
height
|
||||
}
|
||||
}
|
||||
images {
|
||||
url
|
||||
alt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user