- 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
85 lines
1.1 KiB
TypeScript
85 lines
1.1 KiB
TypeScript
import { gql } from "@apollo/client";
|
|
|
|
export const PRODUCT_VARIANT_FRAGMENT = gql`
|
|
fragment ProductVariantFragment on ProductVariant {
|
|
id
|
|
name
|
|
sku
|
|
quantityAvailable
|
|
weight {
|
|
value
|
|
unit
|
|
}
|
|
media {
|
|
id
|
|
url
|
|
alt
|
|
}
|
|
pricing {
|
|
price {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
net {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
onSale
|
|
discount {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
}
|
|
attributes {
|
|
attribute {
|
|
name
|
|
slug
|
|
}
|
|
values {
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const CHECKOUT_LINE_FRAGMENT = gql`
|
|
fragment CheckoutLineFragment on CheckoutLine {
|
|
id
|
|
quantity
|
|
totalPrice {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
variant {
|
|
id
|
|
name
|
|
sku
|
|
product {
|
|
id
|
|
name
|
|
slug
|
|
media {
|
|
id
|
|
url
|
|
alt
|
|
}
|
|
}
|
|
pricing {
|
|
price {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|