31 January 2023
Composable Commerce
HTTP API
Enhancement
CartsOrdersGraphQL

To align with the HTTP API, multiple Shipping Methods are now supported on Carts and Orders in the GraphQL API.

Changes:

  • [GraphQL API] Added the following types to the GraphQL schema: AddCartCustomShippingMethod, AddCartShippingMethod, CustomShippingDraft, MethodTaxRate, RemoveCartShippingMethod, Shipping, ShippingDraft, ShippingMode.
  • [GraphQL API] Changed the MyCartDraft type:
    • Input field shippingMode was added to MyCartDraft type
    • Input field customShipping was added to MyCartDraft type
    • Input field shipping was added to MyCartDraft type
  • [GraphQL API] Changed the CartDraft type:
    • Input field customShipping was added to CartDraft type
    • Input field shipping was added to CartDraft type
    • Input field shippingMode was added to CartDraft type
  • [GraphQL API] Changed the CartUpdateAction type:
    • Input field addCustomShippingMethod was added to CartUpdateAction type
    • Input field removeShippingMethod was added to CartUpdateAction type
    • Input field addShippingMethod was added to CartUpdateAction type
  • [GraphQL API] Changed the Cart type:
    • Added the taxedShippingPrice field to the Cart type.
    • Added the shipping field to the Cart type.
    • Added the shippingMode field to the Cart type.
  • [GraphQL API] Changed the Order type:
    • Added the taxedShippingPrice field to the Order type.
    • Added the shipping field to the Order type.
    • Added the shippingMode field to the Order type.
  • [GraphQL API] Changed the LineItem type:
    • Added the perMethodTaxRate field to the LineItem type.
    • Added the taxedPricePortions field to the LineItem type.
  • [GraphQL API] Changed the ShippingTargetDraft type:
    • Added the shippingMethodKey field to the ShippingTargetDraft type.

The following changes were introduced in terms of GraphQL SDL:

extend type Cart {
  shipping: [Shipping!]!
  shippingMode: ShippingMode!
  taxedShippingPrice: TaxedPrice
}

extend type Order {
  shipping: [Shipping!]!
  shippingMode: ShippingMode!
  taxedShippingPrice: TaxedPrice
}

extend type LineItem {
  perMethodTaxRate: [MethodTaxRate!]!
  taxedPricePortions: [MethodTaxedPrice!]!
}

extend input MyCartDraft {
  customShipping: [CustomShippingDraft!] = []
  shipping: [ShippingDraft!] = []
  shippingMode: ShippingMode = Single
}

extend input CartDraft {
  customShipping: [CustomShippingDraft!] = []
  shipping: [ShippingDraft!] = []
  shippingMode: ShippingMode = Single
}

extend input CartUpdateAction {
  addCustomShippingMethod: AddCartCustomShippingMethod
  addShippingMethod: AddCartShippingMethod
  removeShippingMethod: RemoveCartShippingMethod
}

extend input ShippingTargetDraft {
  shippingMethodKey: String
}

input AddCartCustomShippingMethod {
  shippingKey: String!
  shippingMethodName: String!
  shippingAddress: AddressInput!
  shippingRate: ShippingRateDraft!
  shippingRateInput: ShippingRateInputDraft
  taxCategory: ResourceIdentifierInput
  externalTaxRate: ExternalTaxRateDraft
  custom: CustomFieldsDraft
  deliveries: [DeliveryDraft!] = []
}

input AddCartShippingMethod {
  shippingKey: String!
  shippingMethod: ResourceIdentifierInput!
  externalTaxRate: ExternalTaxRateDraft
  shippingAddress: AddressInput!
  shippingRateInput: ShippingRateInputDraft
  custom: CustomFieldsDraft
  deliveries: [DeliveryDraft!] = []
}

input CustomShippingDraft {
  key: String!
  shippingMethodName: String!
  shippingAddress: AddressInput!
  shippingRate: ShippingRateDraft!
  shippingRateInput: ShippingRateInputDraft
  taxCategory: ReferenceInput
  externalTaxRate: ExternalTaxRateDraft
  deliveries: [DeliveryDraft!]
  custom: CustomFieldsDraft
}

type MethodTaxRate {
  shippingMethodKey: String!
  taxRate: TaxRate
}

input RemoveCartShippingMethod {
  shippingKey: String!
}

type Shipping {
  shippingKey: String
  shippingInfo: ShippingInfo
  shippingAddress: Address
  shippingRateInput: ShippingRateInput
  shippingCustomFields: CustomFieldsType
}

input ShippingDraft {
  key: String!
  shippingMethod: ResourceIdentifierInput
  shippingAddress: AddressInput!
  shippingRateInput: ShippingRateInputDraft
  externalTaxRate: ExternalTaxRateDraft
  deliveries: [DeliveryDraft!]
  custom: CustomFieldsDraft
}

enum ShippingMode {
  "Allows multiple shipping methods for the cart with their respective shipping addresses"
  Multiple

  "Allows only one shipping method and shipping address for the cart"
  Single
}