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:
74
src/lib/saleor/fragments/Checkout.ts
Normal file
74
src/lib/saleor/fragments/Checkout.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { gql } from "@apollo/client";
|
||||
import { CHECKOUT_LINE_FRAGMENT } from "./Variant";
|
||||
|
||||
export const ADDRESS_FRAGMENT = gql`
|
||||
fragment AddressFragment on Address {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
companyName
|
||||
streetAddress1
|
||||
streetAddress2
|
||||
city
|
||||
postalCode
|
||||
country {
|
||||
code
|
||||
country
|
||||
}
|
||||
countryArea
|
||||
phone
|
||||
isDefaultBillingAddress
|
||||
isDefaultShippingAddress
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_FRAGMENT = gql`
|
||||
fragment CheckoutFragment on Checkout {
|
||||
id
|
||||
token
|
||||
email
|
||||
isShippingRequired
|
||||
lines {
|
||||
...CheckoutLineFragment
|
||||
}
|
||||
shippingPrice {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
subtotalPrice {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
totalPrice {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
shippingAddress {
|
||||
...AddressFragment
|
||||
}
|
||||
billingAddress {
|
||||
...AddressFragment
|
||||
}
|
||||
shippingMethods {
|
||||
id
|
||||
name
|
||||
price {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
availablePaymentGateways {
|
||||
id
|
||||
name
|
||||
}
|
||||
note
|
||||
}
|
||||
${CHECKOUT_LINE_FRAGMENT}
|
||||
${ADDRESS_FRAGMENT}
|
||||
`;
|
||||
Reference in New Issue
Block a user