- 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
75 lines
1.1 KiB
TypeScript
75 lines
1.1 KiB
TypeScript
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}
|
|
`;
|