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:
154
src/lib/saleor/mutations/Checkout.ts
Normal file
154
src/lib/saleor/mutations/Checkout.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
import { gql } from "@apollo/client";
|
||||
import { CHECKOUT_FRAGMENT } from "../fragments/Checkout";
|
||||
|
||||
export const CHECKOUT_CREATE = gql`
|
||||
mutation CheckoutCreate($input: CheckoutCreateInput!) {
|
||||
checkoutCreate(input: $input) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_LINES_ADD = gql`
|
||||
mutation CheckoutLinesAdd($checkoutId: ID!, $lines: [CheckoutLineInput!]!) {
|
||||
checkoutLinesAdd(checkoutId: $checkoutId, lines: $lines) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_LINES_UPDATE = gql`
|
||||
mutation CheckoutLinesUpdate($checkoutId: ID!, $lines: [CheckoutLineUpdateInput!]!) {
|
||||
checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lines) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_LINES_DELETE = gql`
|
||||
mutation CheckoutLinesDelete($checkoutId: ID!, $lineIds: [ID!]!) {
|
||||
checkoutLinesDelete(checkoutId: $checkoutId, lines: $lineIds) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_SHIPPING_ADDRESS_UPDATE = gql`
|
||||
mutation CheckoutShippingAddressUpdate($checkoutId: ID!, $shippingAddress: AddressInput!) {
|
||||
checkoutShippingAddressUpdate(checkoutId: $checkoutId, shippingAddress: $shippingAddress) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_BILLING_ADDRESS_UPDATE = gql`
|
||||
mutation CheckoutBillingAddressUpdate($checkoutId: ID!, $billingAddress: AddressInput!) {
|
||||
checkoutBillingAddressUpdate(checkoutId: $checkoutId, billingAddress: $billingAddress) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_SHIPPING_METHOD_UPDATE = gql`
|
||||
mutation CheckoutShippingMethodUpdate($checkoutId: ID!, $shippingMethodId: ID!) {
|
||||
checkoutShippingMethodUpdate(checkoutId: $checkoutId, shippingMethodId: $shippingMethodId) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_COMPLETE = gql`
|
||||
mutation CheckoutComplete($checkoutId: ID!) {
|
||||
checkoutComplete(checkoutId: $checkoutId) {
|
||||
order {
|
||||
id
|
||||
number
|
||||
status
|
||||
created
|
||||
total {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHECKOUT_EMAIL_UPDATE = gql`
|
||||
mutation CheckoutEmailUpdate($checkoutId: ID!, $email: String!) {
|
||||
checkoutEmailUpdate(checkoutId: $checkoutId, email: $email) {
|
||||
checkout {
|
||||
...CheckoutFragment
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
${CHECKOUT_FRAGMENT}
|
||||
`;
|
||||
Reference in New Issue
Block a user