- Add Apollo Client for Saleor GraphQL API - Create GraphQL fragments (Product, Variant, Checkout) - Create GraphQL queries (Products, Checkout) - Create GraphQL mutations (Checkout operations) - Add TypeScript types for Saleor entities - Add product helper functions - Install @apollo/client and graphql dependencies Part of WordPress/WooCommerce → Saleor migration
82 lines
1.2 KiB
TypeScript
82 lines
1.2 KiB
TypeScript
import { gql } from "@apollo/client";
|
|
import { PRODUCT_VARIANT_FRAGMENT } from "./Variant";
|
|
|
|
export const PRODUCT_FRAGMENT = gql`
|
|
fragment ProductFragment on Product {
|
|
id
|
|
name
|
|
slug
|
|
description
|
|
seoTitle
|
|
seoDescription
|
|
translation(languageCode: $locale) {
|
|
id
|
|
name
|
|
slug
|
|
description
|
|
seoTitle
|
|
seoDescription
|
|
}
|
|
variants {
|
|
...ProductVariantFragment
|
|
}
|
|
media {
|
|
id
|
|
url
|
|
alt
|
|
type
|
|
}
|
|
category {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
metadata {
|
|
key
|
|
value
|
|
}
|
|
}
|
|
${PRODUCT_VARIANT_FRAGMENT}
|
|
`;
|
|
|
|
export const PRODUCT_LIST_ITEM_FRAGMENT = gql`
|
|
fragment ProductListItemFragment on Product {
|
|
id
|
|
name
|
|
slug
|
|
description
|
|
translation(languageCode: $locale) {
|
|
id
|
|
name
|
|
slug
|
|
description
|
|
}
|
|
variants {
|
|
id
|
|
name
|
|
sku
|
|
quantityAvailable
|
|
pricing {
|
|
price {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
onSale
|
|
discount {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
}
|
|
}
|
|
media {
|
|
id
|
|
url
|
|
alt
|
|
}
|
|
}
|
|
`;
|