feat(saleor): Phase 1 - GraphQL Client Setup
- 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
This commit is contained in:
84
src/lib/saleor/fragments/Variant.ts
Normal file
84
src/lib/saleor/fragments/Variant.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user