Added basis setup and type generation for the products queries

This commit is contained in:
royderks
2021-04-16 16:28:52 +02:00
committed by Zaiste
parent ffe5a1c20e
commit b5e21a54b3
25 changed files with 32173 additions and 14243 deletions

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}
}
}