extend type Query {
  "Query to get a filtered list of Orders"
  filterOrders(
    "Shop ID"
    shopId: ID!,

    "Input Conditions for fliter (use either 'any' or 'all' not both)"
    conditions: FilterConditionsInput,

    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int

    "Return results sorted in this order"
    sortOrder: SortOrder = desc,

    "By default, orders are sorted by createdAt. Set this to sort by one of the other allowed fields"
    sortBy: OrdersSortByField = createdAt
  ): OrderConnection
  
  "Get an order by its ID"
  orderById(
    "The order ID"
    id: ID!,

    "The shop that owns the order"
    shopId: ID!,

    "A valid anonymous access token for this order. Required if the order is not linked with an account."
    token: String
  ): Order

  "Get all orders for a single account, optionally limited to certain shop IDs and certain orderStatus"
  orders(
    "Filters to apply to a list of orders"
    filters: OrderFilterInput

    "Provide a list of shop IDs from which you want to get orders from"
    shopIds: [ID],

    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int,

    "Return results sorted in this order"
    sortOrder: SortOrder = desc,

    "By default, orders are sorted by when they were created, newest first. Set this to sort by one of the other allowed fields"
    sortBy: OrdersSortByField = createdAt
  ): OrderConnection!

  "Get all orders for a single account, optionally limited to certain shop IDs and certain orderStatus"
  ordersByAccountId(
    "Limit to orders placed by this account"
    accountId: ID!,

    "Limit to orders with one of these statuses"
    orderStatus: [String],

    "Limit to orders owned by one of these shops"
    shopIds: [ID]!,

    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int,

    "Return results sorted in this order"
    sortOrder: SortOrder = desc,

    "By default, orders are sorted by when they were created, newest first. Set this to sort by one of the other allowed fields"
    sortBy: OrdersByAccountIdSortByField = createdAt
  ): OrdersByAccountIdConnection!

  "Get an order by its reference ID (the ID shown to customers)"
  orderByReferenceId(
    "The order reference ID (the ID shown to customers)"
    id: ID!,

    "The shop that owns the order"
    shopId: ID!,

    "A valid anonymous access token for this order. Required if the order is not linked with an account."
    token: String
  ): Order

  "Get refunds applied to an order by order ID"
  refunds(
    "The order ID"
    orderId: ID!,

    "The shop that owns the order"
    shopId: ID!,

    "A valid anonymous access token for this order. Required if the order is not linked with an account."
    token: String
  ): [Refund]

  "Get refunds applied to a specific payment by payment ID"
  refundsByPaymentId(
    "The order ID"
    orderId: ID!,

    "The ID of one of the payments made for this order"
    paymentId: ID!,

    "The shop that owns the order"
    shopId: ID!,

    "A valid anonymous access token for this order. Required if the order is not linked with an account."
    token: String
  ): [Refund]

  "Validate the order for correctness & completeness before placing the order"
  validateOrder(
    "input with order and payment objects similar to the one used for placeOrder"
    input: ValidateOrderInput!
  ): ValidateOrderPayload!
}

extend type Mutation {
  """
  Use this mutation to add a new order fulfillment group to an order. It must have at least one
  item. Items may be provided or moved from another existing group or both.
  """
  addOrderFulfillmentGroup(
    "Mutation input"
    input: AddOrderFulfillmentGroupInput!
  ): AddOrderFulfillmentGroupPayload!

  """
  Use this mutation to cancel one item of an order, either for the full ordered quantity
  or for a partial quantity. If partial, the item will be split into two items and the
  original item will have a lower quantity and will be canceled.

  If this results in all items in a fulfillment group being canceled, the group will also
  be canceled. If this results in all fulfillment groups being canceled, the full order will
  also be canceled.
  """
  cancelOrderItem(
    "Mutation input"
    input: CancelOrderItemInput!
  ): CancelOrderItemPayload!

  "Use this mutation to create a refund on a payment method used to make the order"
  createRefund(
    "Mutation input"
    input: CreateRefundInput!
  ): CreateRefundPayload!

  """
  Use this mutation to move one or more items between existing order fulfillment groups.
  """
  moveOrderItems(
    "Mutation input"
    input: MoveOrderItemsInput!
  ): MoveOrderItemsPayload!

  """
  Use this mutation to place an order, providing information necessary to pay for it.
  The order will be placed only if authorization is successful for all submitted payments.
  """
  placeOrder(
    "Mutation input"
    input: PlaceOrderInput!
  ): PlaceOrderPayload!

  """
  Use this mutation to reduce the quantity of one item of an order and create
  a new item for the remaining quantity in the same fulfillment group, and with the
  same item status. You may want to do this if you are only able to partially fulfill
  the item order right now.
  """
  splitOrderItem(
    "Mutation input"
    input: SplitOrderItemInput!
  ): SplitOrderItemPayload!

  """
  Use this mutation to update order details after the order has been placed.
  """
  updateOrder(
    "Mutation input"
    input: UpdateOrderInput!
  ): UpdateOrderPayload!

  """
  Use this mutation to update an order fulfillment group status and tracking information.
  """
  updateOrderFulfillmentGroup(
    "Mutation input"
    input: UpdateOrderFulfillmentGroupInput!
  ): UpdateOrderFulfillmentGroupPayload!
}

"Allowed values for the `OrderFulfillmentGroupItems` sortBy parameter"
enum OrderFulfillmentGroupItemsSortByField {
  "Sort by the item ID"
  _id

  "Sort by the date and time when the item was added to the order"
  addedAt
}

"The fields by which you are allowed to sort any query that returns a `OrdersByAccountIdConnection`"
enum OrdersByAccountIdSortByField {
  "Sort by the order ID"
  _id

  "Sort by the date and time when the order was placed"
  createdAt
}

"The fields by which you are allowed to sort any query that returns a `OrderConnection`"
enum OrdersSortByField {
  "Sort by the order ID"
  _id

  "Sort by the date and time when the order was placed"
  createdAt
}

"""
Wraps a list of `Order`s, providing pagination cursors and information.

For information about what Relay-compatible connections are and how to use them, see the following articles:
- [Relay Connection Documentation](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections)
- [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm)
- [Using Relay-style Connections With Apollo Client](https://www.apollographql.com/docs/react/recipes/pagination.html)
"""
type OrderConnection {
  "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each"
  edges: [OrderEdge]

  """
  You can request the `nodes` directly to avoid the extra wrapping that `NodeEdge` has,
  if you know you will not need to paginate the results.
  """
  nodes: [Order]

  "Information to help a client request the next or previous page"
  pageInfo: PageInfo!

  "The total number of nodes that match your query"
  totalCount: Int!
}


"""
Wraps a list of `Order`s, providing pagination cursors and information.

For information about what Relay-compatible connections are and how to use them, see the following articles:
- [Relay Connection Documentation](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections)
- [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm)
- [Using Relay-style Connections With Apollo Client](https://www.apollographql.com/docs/react/recipes/pagination.html)
"""
type OrdersByAccountIdConnection {
  "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each"
  edges: [OrdersByAccountIdEdge]

  """
  You can request the `nodes` directly to avoid the extra wrapping that `NodeEdge` has,
  if you know you will not need to paginate the results.
  """
  nodes: [Order]

  "Information to help a client request the next or previous page"
  pageInfo: PageInfo!

  "The total number of nodes that match your query"
  totalCount: Int!
}

"A connection edge in which each node is a `Order` object"
type OrderEdge implements NodeEdge {
  "The cursor that represents this node in the paginated results"
  cursor: ConnectionCursor!

  "The order"
  node: Order
}

"A connection edge in which each node is a `Order` object"
type OrdersByAccountIdEdge implements NodeEdge {
  "The cursor that represents this node in the paginated results"
  cursor: ConnectionCursor!

  "The order"
  node: Order
}

"""
Wraps a list of `OrderItem`s, providing pagination cursors and information.

For information about what Relay-compatible connections are and how to use them, see the following articles:
- [Relay Connection Documentation](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections)
- [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm)
- [Using Relay-style Connections With Apollo Client](https://www.apollographql.com/docs/react/recipes/pagination.html)
"""
type OrderItemConnection {
  "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each"
  edges: [OrderItemEdge]

  """
  You can request the `nodes` directly to avoid the extra wrapping that `NodeEdge` has,
  if you know you will not need to paginate the results.
  """
  nodes: [OrderItem]

  "Information to help a client request the next or previous page"
  pageInfo: PageInfo!

  "The total number of nodes that match your query"
  totalCount: Int!
}

"A connection edge in which each node is a `OrderItem` object"
type OrderItemEdge implements NodeEdge {
  "The cursor that represents this node in the paginated results"
  cursor: ConnectionCursor!

  "The order item"
  node: OrderItem
}

"One attribute of an order item"
type OrderItemAttribute {
  "The attribute label, e.g., Color"
  label: String

  "The attribute value, e.g., Blue"
  value: String
}

"A summary of the totals for this order"
type OrderSummary {
  "The total of all discounts applied, as a positive number"
  discountTotal: Money!

  "The calculated tax-exclusive tax rate on all items and fulfillment prices (taxTotal / taxableAmount)"
  effectiveTaxRate: Rate!

  "The total price of all chosen fulfillment methods"
  fulfillmentTotal: Money!

  "The combined prices of all cart items"
  itemTotal: Money!

  "The total estimated tax that has not already been included in the item prices"
  taxTotal: Money!

  "The total amount that was deemed taxable by the tax service"
  taxableAmount: Money!

  "The sum of `itemTotal`, `fulfillmentTotal`, and `taxTotal`, minus `discountTotal`"
  total: Money!
}

"""
A single item in an order. The item contains information about a purchase.
"""
type OrderItem implements Node {
  "The order item ID"
  _id: ID!

  """"
  The date and time at which this item was first added to the associated cart.
  If an item is added, removed, and then added again, this will reflect the most recent addition.
  However, if an item is added twice, the quantity will increase but this date will remain
  the initial added date.
  """
  addedAt: DateTime

  """
  FUTURE. Additional attributes of the chosen item. For example, if this item is for a product, socks, where `blue` and `small`
  options were chosen for some configurable attributes, then `color:blue` and `size:small` will be indicated here.
  """
  attributes: [OrderItemAttribute]

  "If this order item is canceled, the reason for cancelation, if provided"
  cancelReason: String

  "The date and time at which the order item was created"
  createdAt: DateTime!

  "The URLs for a picture of the item in various sizes"
  imageURLs: ImageSizes

  "Arbitrary additional metadata about this cart item."
  metafields: [Metafield]

  "The short title of the associated option, if this is an option item"
  optionTitle: String

  "Packing information such as item weight, height, length, and depth. Used for calculating shipping rates."
  parcel: ShippingParcel

  "The price of the item at the time of purchase"
  price: Money!

  "The product and chosen options"
  productConfiguration: ProductConfiguration!

  "The product's slug"
  productSlug: String

  "The list of tags that have been applied to this product"
  productTags(
    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int,

    "Return results sorted in this order"
    sortOrder: SortOrder = asc,

    "By default, tags are sorted by ID. Set this to sort by one of the other allowed fields"
    sortBy: TagSortByField = _id
  ): TagConnection

  "The type of product, used to display cart items differently"
  productType: String

  "The product vendor"
  productVendor: String

  "The quantity of this item that has been added to the cart. This must be a positive integer. Remove this `CartItem` from it's associated cart if you want `0` of this item."
  quantity: Int!

  "The shop associated with this cart item."
  shop: Shop!

  "The machine-readable order item status."
  status: String!

  "The price of the item multiplied by the quantity of this item ordered"
  subtotal: Money!

  "A title for use in orders that conveys the selected product's title + chosen options"
  title: String!

  "The date and time at which this item was last updated"
  updatedAt: DateTime!

  "The selected variant title"
  variantTitle: String
}

"""
Extra data for an order fulfillment group with type `shipping`
"""
type ShippingOrderFulfillmentGroupData {
  "The address to ship to"
  shippingAddress: Address!
}

"Extra data for an order fulfillment group"
union OrderFulfillmentGroupData = ShippingOrderFulfillmentGroupData

"An order fulfillment group"
type OrderFulfillmentGroup implements Node {
  "The order fulfillment group ID"
  _id: ID!

  "Information needed by the selected fulfillment method to properly fulfill the order"
  data: OrderFulfillmentGroupData

  "The order status for display in UI"
  displayStatus(
    """
    The language in which you want the status. If no translation is available for this language,
    it will be in the default language of the shop that owns the order.
    """
    language: String!
  ): String!

  "The items that are part of this fulfillment group"
  items(
    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int,

    "Return results sorted in this order"
    sortOrder: SortOrder = desc,

    "By default, order items are sorted by when they were added to the order, newest first. Set this to sort by one of the other allowed fields"
    sortBy: OrderFulfillmentGroupItemsSortByField = addedAt
  ): OrderItemConnection

  "The fulfillment method that was selected, with its price quote"
  selectedFulfillmentOption: FulfillmentOption!

  "The shipping label URL"
  shippingLabelUrl: String

  "The shop responsible for fulfilling this order"
  shop: Shop!

  "The machine-readable fulfillment group status."
  status: String!

  "A summary of the totals for this group"
  summary: OrderSummary!

  "Total quantity of all items in the group"
  totalItemQuantity: Int!

  "The order fulfillment group shipment tracking number"
  tracking: String

  "The order fulfillment group shipment tracking URL"
  trackingUrl: String

  """
  The fulfillment type. Any valid type that has been registered by a fulfillment plugin. Examples: `shipping`, `digital`
  """
  type: FulfillmentType!
}

"An order"
type Order implements Node {
  "The Order ID"
  _id: ID!

  "The account that placed the order. Some orders are created for anonymous users. Anonymous orders have a null account."
  account: Account

  "Full name(s) involved with payment. Payment can be made by one or more than one person"
  billingName: String

  "The ID of the cart that created this order. Carts are deleted after becoming orders, so this is just a reference."
  cartId: ID

  "The date and time at which the cart was created, which is when the first item was added to it."
  createdAt: DateTime!

  "The order status for display in UI"
  displayStatus(
    """
    The language in which you want the status. If no translation is available for this language,
    it will be in the default language of the shop that owns the order.
    """
    language: String!
  ): String!

  "An email address that has been associated with the cart"
  email: String

  "One or more fulfillment groups. Each of these are fulfilled and charged as separate orders."
  fulfillmentGroups: [OrderFulfillmentGroup]!

  "Notes about the order. This will always return an array but it may be empty"
  notes: [OrderNote]!

  """
  Payments that collectively have paid or will pay for the total amount due for this order.
  May be null if no payment is needed.
  """
  payments: [Payment]

  """
  An ID by which the customer can reference this order when enquiring about it. A storefront user
  interface may show this to customers. Do not display other IDs (`_id`) to customers.
  """
  referenceId: String!

  "Refunds that have been applied to the payments on this order."
  refunds: [Refund]

  "The shop through which the order was placed"
  shop: Shop!

  "The machine-readable order status."
  status: String!

  "A summary of the totals for all fulfillment groups for this order"
  summary: OrderSummary!

  "Total quantity of all items in the order"
  totalItemQuantity: Int!

  "The date and time at which this order was last updated"
  updatedAt: DateTime!
}

"A note about an order"
type OrderNote {
  "The account who wrote this note"
  account: Account!

  "The content of the note"
  content: String!

  "The date and time at which this note was created"
  createdAt: DateTime!

  "The date and time at which this note was last updated"
  updatedAt: DateTime!
}

"A refund of a payment on an order"
type Refund implements Node {
  "The refund ID"
  _id: ID!

  "The amount of the refund"
  amount: Money!

  "The date and time at which the refund was created"
  createdAt: DateTime!

  "The display name of the payment refunded to"
  paymentDisplayName: String!

  "The ID of the payment this refund is applied to"
  paymentId: ID!

  "The reason for the refund"
  reason: String
}

"Input for an `OrderFulfillmentGroupItem`"
input OrderFulfillmentGroupItemInput {
  "The date and time at which this item was first added to the source cart, if this is something you want to track"
  addedAt: DateTime

  """
  The price of the item, in the `order.currencyCode` currency. This value is not trusted; the actual price
  is confirmed by the Order service. However, providing this value prevents an order being created for an
  amount that does not match what was shown to the shopper in order preview.
  """
  price: Float!

  "The product and chosen options"
  productConfiguration: ProductConfigurationInput!

  "The desired quantity of this item. This must be a positive integer."
  quantity: Int!
}

"Information needed by the selected fulfillment method to properly fulfill the order"
input OrderFulfillmentGroupDataInput {
  "The mailing address to which this fulfillment group should be shipped"
  shippingAddress: AddressInput
}

"Input for an `OrderFulfillmentGroup`"
input OrderFulfillmentGroupInput {
  "Information needed by the selected fulfillment method to properly fulfill the order"
  data: OrderFulfillmentGroupDataInput

  "The list of items to be ordered"
  items: [OrderFulfillmentGroupItemInput]!

  "The ID of the fulfillment method to be used for this order group"
  selectedFulfillmentMethodId: ID!

  "The shop that owns these items and needs to fulfill this part of the order"
  shopId: ID!

  """
  The total price of the items, fulfillment, and taxes, for this group, less any discounts, in the
  `order.currencyCode` currency. This value is not trusted; the actual total is calculated by the
  Order service. However, providing this value prevents an order being created for an amount that
  does not match what was shown to the shopper in order preview.
  """
  totalPrice: Float

  """
  The fulfillment type. Any valid type that has been registered by a fulfillment plugin. Examples: `shipping`, `digital`
  """
  type: FulfillmentType!
}

"Similar to `OrderFulfillmentGroupInput` but `items` can be omitted if moving existing items to the new group"
input OrderFulfillmentGroupExistingOrderInput {
  "Information needed by the selected fulfillment method to properly fulfill the order"
  data: OrderFulfillmentGroupDataInput

  "The list of items to be ordered"
  items: [OrderFulfillmentGroupItemInput]

  "The ID of the fulfillment method to be used for this order group"
  selectedFulfillmentMethodId: ID!

  "The shop that owns these items and needs to fulfill this part of the order"
  shopId: ID!

  """
  The total price of the items, fulfillment, and taxes, for this group, less any discounts, in the
  `order.currencyCode` currency. This value is not trusted; the actual total is calculated by the
  Order service. However, providing this value prevents an order being created for an amount that
  does not match what was shown to the shopper in order preview.
  """
  totalPrice: Float

  """
  The fulfillment type. Any valid type that has been registered by a fulfillment plugin. Examples: `shipping`, `digital`
  """
  type: FulfillmentType!
}

"Input for placing an order"
input OrderInput {
  """
  The ID of the cart that is becoming an order. This is optional, and you can create an order without ever
  creating a cart. If you do have a cart, there are two good reasons to provide this. First, it serves as a
  reference. Second, it allows the Cart service to automatically delete the related cart after the order is
  created.
  """
  cartId: String

  "The code for the currency in which all values are being provided"
  currencyCode: String!

  """
  An email address to use for order tracking and correspondence. If a logged in user is placing an order,
  we recommend that you use their "orders" email address, if they have one, or their default email address.
  Or you can ask them to provide any email address.
  """
  email: String!

  """
  One or more fulfillment groups for the order. These are the actual orders that need to be fulfilled,
  separate by shop, fulfillment type, and shipping origin or destination.
  """
  fulfillmentGroups: [OrderFulfillmentGroupInput]!

  """
  The shop through which the order should be placed. Payment settings from this shop will be used. Note that
  each fulfillment group also has a shop ID, which represents the shop that needs to fulfill that part of the
  order, and those shop IDs may or may not match this one.
  """
  shopId: String!
}

"Input for adding order payments"
input PaymentInput {
  """
  Amount to charge, which must be less than or equal to the order total. This is assumed
  to be in the same currency as the order. Set to `null` to charge the remaining amount
  to this payment method, which might be the full order total if this is the only payment.
  """
  amount: Float!

  """
  The billing address entered by the shopper. If omitted, the billing address on the order input
  will be used. Some payment methods may not require a billing address but others will fail
  authorization without one, so be sure that client UI code is aware of which payment methods
  require collecting one.
  """
  billingAddress: AddressInput

  "Any additional user-provided input necessary to authorize and capture the payment"
  data: JSONObject

  "The name of the payment method to use for this payment"
  method: PaymentMethodName!
}

"Input for the addOrderFulfillmentGroup mutation"
input AddOrderFulfillmentGroupInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "The order fulfillment group input, used to build the new group"
  fulfillmentGroup: OrderFulfillmentGroupExistingOrderInput!

  "Optional list of order item IDs that should be moved from an existing group to the new group"
  moveItemIds: [ID]

  "ID of the order that has the item you want to add the group to"
  orderId: ID!
}

"Input for the cancelOrderItem mutation"
input CancelOrderItemInput {
  "Quantity to cancel. Must be equal to or less than the item quantity."
  cancelQuantity: Int!

  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "ID of the item order you want to cancel"
  itemId: ID!

  "ID of the order that has the item you want to cancel"
  orderId: ID!

  """
  An optional free text reason for cancellation, which may be shown to operators
  or to the user who placed the order.
  """
  reason: String
}

"Input for the cancelOrderItem mutation"
input CreateRefundInput {
  "Amount to cancel. Must be equal to or less than the remaining non-refunded payment amount for this payment method."
  amount: Float!

  "ID of the order that has the item you want to cancel"
  orderId: ID!

  "ID of the payment that you want to refund"
  paymentId: ID!

  """
  An optional free text reason for refund, which may be shown to operators
  or to the user who requested the refund.
  """
  reason: String
}

"Input for the placeOrder mutation"
input PlaceOrderInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "The order to be placed, if payment is accepted"
  order: OrderInput!

  """
  The information necessary to pay. Collect this information from the shopper during a checkout flow.
  You need not provide any payment input if the total is zero.
  The total of all payment input `amount` fields must add up to the order total. The first payment
  method where the `amount` field is `null` will be charged the remainder due.
  """
  payments: [PaymentInput]
}

"Input for the moveOrderItems mutation"
input MoveOrderItemsInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "The ID of the order fulfillment group from which all the items are to be moved."
  fromFulfillmentGroupId: ID!

  "The list of item IDs to move. The full quantity must be moved."
  itemIds: [ID]!

  "ID of the order that has the items you want to move"
  orderId: ID!

  "The ID of the order fulfillment group to which all the items are to be moved."
  toFulfillmentGroupId: ID!
}

"Input for the splitOrderItem mutation"
input SplitOrderItemInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "ID of the item order you want to split"
  itemId: ID!

  "The quantity that will be transferred to a new order item on the same fulfillment group."
  newItemQuantity: Int!

  "ID of the order that has the item you want to split"
  orderId: ID!
}

"Input for the updateOrder mutation"
input UpdateOrderInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "Set the order email to this"
  email: String

  "ID of the order to update"
  orderId: ID!

  "Set the current order status to this"
  status: String
}

"Input for the updateOrderFulfillmentGroup mutation"
input UpdateOrderFulfillmentGroupInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "ID of the order fulfillment group to update"
  orderFulfillmentGroupId: ID!

  "ID of the order to update"
  orderId: ID!

  "Set the current order fulfillment group status to this"
  status: String

  "Set this as the current order fulfillment group shipment tracking reference"
  tracking: String

  "Set this as the current order fulfillment group shipment tracking URL"
  trackingUrl: String
}

"Response payload for the addOrderFulfillmentGroup mutation"
type AddOrderFulfillmentGroupPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "ID of the added fulfillment group"
  newFulfillmentGroupId: ID!

  "The updated order"
  order: Order!
}

"Response payload for the cancelOrderItem mutation"
type CancelOrderItemPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated order"
  order: Order!
}

"Response payload for the createRefund mutation"
type CreateRefundPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated order"
  order: Order!
}

"Response payload for the moveOrderItems mutation"
type MoveOrderItemsPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated order"
  order: Order!
}

"Input for the validateOrder query"
input ValidateOrderInput {
  "The order to be validated and created, if payment is accepted"
  order: OrderInput!

  """
  The information necessary to pay. Collect this information from the shopper during a checkout flow.
  You need not provide any payment input if the total is zero.
  The total of all payment input `amount` fields must add up to the order total. The first payment
  method where the `amount` field is `null` will be charged the remainder due.
  """
  payments: [PaymentInput]
}

type ValidationErrors {
  errorName: String,
  errorType: String,
  errorField: String,
  fieldValue: String,
  errorMessage: String
}

"Response payload for the validateOrder query"
type ValidateOrderPayload {
  "Orders that were created"
  errors: [ValidationErrors]

  "Validation Result"
  success: Boolean
}

"Response payload for the placeOrder mutation"
type PlaceOrderPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "Orders that were created"
  orders: [Order]!

  "If you are not logged in, this will be a token that can be used for future requests"
  token: String
}

"Response payload for the splitOrderItem mutation"
type SplitOrderItemPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The ID of the new order item that was created"
  newItemId: ID!

  "The updated order"
  order: Order!
}

"Response payload for the updateOrder mutation"
type UpdateOrderPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated order"
  order: Order!
}

"Response payload for the updateOrderFulfillmentGroup mutation"
type UpdateOrderFulfillmentGroupPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated order"
  order: Order!
}

"Available order fulfillment statuses"
enum OrderFulfillmentStatus {
  "An order that has been completed"
  completed

  "Newly created order that needs processing"
  new

  "An order that is currently being processed"
  processing
}

"Order payment status"
enum OrderPaymentStatus {
  "Payments that have been successfully processed"
  completed

  "A payment intent has been created"
  created
}

"Order status"
enum OrderStatus {
  "Canceled order"
  canceled

  "A completed order"
  completed

  "A new order that needs processing"
  new

  "An order that is being processed"
  processing
}

"Input for the createdAt database field"
input CreatedAtInput {
  "Start date, inclusive"
  gte: DateTime

  "End date, inclusive"
  lte: DateTime
}

"Input type for filters to by applied to an Orders list"
input OrderFilterInput {
  "A createdAt date range to filter by"
  createdAt: CreatedAtInput

  "An order's fulfillment status"
  fulfillmentStatus: [OrderFulfillmentStatus]

  "An order's payment status"
  paymentStatus: [OrderPaymentStatus]

  "Keywords typed by the user in the search input field"
  searchField: String

  "The order's status to filter by"
  status: OrderStatus
}
