Skip to content

Instantly share code, notes, and snippets.

@skirianov
Created March 9, 2023 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skirianov/53bf3ccebaf668521aac50722da69136 to your computer and use it in GitHub Desktop.
Save skirianov/53bf3ccebaf668521aac50722da69136 to your computer and use it in GitHub Desktop.
productTaxCategory custom GraphQL query for Vue Storefront and commercetools integration
const { ChannelFragment, ProductPriceFragment } = require('@vsf-enterprise/commercetools-api');
// add taxCategory field on products query
module.exports = `
${ProductPriceFragment}
${ChannelFragment}
fragment Images on ProductVariant {
images {
url
label
}
}
fragment Price on ProductVariant {
price(currency: $currency, country: $country, channelId: $channelId) {
...DefaultProductPrice
}
}
fragment Attributes on ProductVariant {
attributesRaw {
name
value
attributeDefinition {
type {
name
}
label(locale: $locale)
}
}
}
fragment Availability on ProductVariant {
availability {
noChannel {
isOnStock
restockableInDays
availableQuantity
}
channels(
includeChannelIds: $includeChannelIds
excludeChannelIds: $excludeChannelIds
limit: $channelLimit
offset: $channelOffset
) {
limit
offset
total
results {
channelRef {
id
}
availability {
isOnStock
restockableInDays
availableQuantity
}
channel {
...ChannelFragment
}
}
}
}
}
fragment DefaultVariant on ProductVariant {
id
sku
...Images
...Price
...Attributes
...Availability
}
fragment category on Category {
id
slug(acceptLanguage: $acceptLanguage)
name(acceptLanguage: $acceptLanguage)
}
query products(
$where: String
$sort: [String!]
$limit: Int
$offset: Int
$skus: [String!]
$locale: Locale!
$acceptLanguage: [Locale!]
$currency: Currency!
$country: Country!
$channelId: String
$includeChannelIds: [String!]
$excludeChannelIds: [String!]
$channelLimit: Int
$channelOffset: Int
) {
products(
where: $where
sort: $sort
limit: $limit
offset: $offset
skus: $skus
) {
offset
count
total
results {
id
taxCategory {
name
rates {
amount
country
includedInPrice
subRates {
name
amount
}
}
}
reviewRatingStatistics {
averageRating,
ratingsDistribution,
count
}
masterData {
current {
slug(acceptLanguage: $acceptLanguage)
name(acceptLanguage: $acceptLanguage)
metaTitle(acceptLanguage: $acceptLanguage)
metaKeywords(acceptLanguage: $acceptLanguage)
metaDescription(acceptLanguage: $acceptLanguage)
description(acceptLanguage: $acceptLanguage)
categoriesRef {
id
}
categories {
...category
parent {
...category
parent {
...category
parent {
...category
}
}
}
}
allVariants {
...DefaultVariant
}
masterVariant {
...DefaultVariant
}
}
}
}
}
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment