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:
81
src/lib/saleor/fragments/Product.ts
Normal file
81
src/lib/saleor/fragments/Product.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user