"Inventory info for a specific product configuration. For inventory managed by the SimpleInventory plugin."
type SimpleInventoryInfo {
  """
  Whether to allow ordering this product configuration when there is insufficient quantity available
  """
  canBackorder: Boolean

  """
  Current quantity of this product configuration in stock
  """
  inventoryInStock: Int

  """
  Current quantity of this product configuration unavailable for ordering. This value is calculated
  by the system based on this product variant being in not-yet-approved orders.
  """
  inventoryReserved: Int

  """
  Whether the SimpleInventory plugin should manage inventory for this product configuration
  """
  isEnabled: Boolean

  """
  The "low quantity" flag will be applied to this product configuration when the available quantity
  is at or below this threshold
  """
  lowInventoryWarningThreshold: Int

  "The product and chosen options this info applies to"
  productConfiguration: ProductConfiguration!
}

"Input for the `recalculateReservedSimpleInventory` mutation"
input RecalculateReservedSimpleInventoryInput {
  "The product and chosen options this info applies to"
  productConfiguration: ProductConfigurationInput!

  "Shop that owns the product"
  shopId: ID!
}

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

  "The updated inventory info"
  inventoryInfo: SimpleInventoryInfo!
}

"Input for the `updateSimpleInventory` mutation. In addition to `shopId`, at least one field to update is required."
input UpdateSimpleInventoryInput {
  """
  Whether to allow ordering this product configuration when there is insufficient quantity available.
  Set this to `true` or `false` if you want to update it.
  """
  canBackorder: Boolean

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

  """
  Current quantity of this product configuration in stock. Set this to an integer if you want to update it.
  """
  inventoryInStock: Int

  """
  Whether the SimpleInventory plugin should manage inventory for this product configuration.
  Set this to `true` or `false` if you want to update it.
  """
  isEnabled: Boolean

  """
  The "low quantity" flag will be applied to this product configuration when the available quantity
  is at or below this threshold. Set this to an integer if you want to update it.
  """
  lowInventoryWarningThreshold: Int

  "The product and chosen options this info applies to"
  productConfiguration: ProductConfigurationInput!

  "Shop that owns the product"
  shopId: ID!
}

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

  "The updated inventory info"
  inventoryInfo: SimpleInventoryInfo!
}

extend type Query {
  """
  Get the SimpleInventory info for a product configuration. Returns `null` if `updateSimpleInventory`
  has never been called for this product configuration.
  """
  simpleInventory(
    "ID of the shop that owns the product"
    shopId: ID!,

    "The product configuration for which you want inventory info"
    productConfiguration: ProductConfigurationInput!
  ): SimpleInventoryInfo
}

extend type Mutation {
  "Force recalculation of the system-managed `inventoryReserved` field based on current order statuses"
  recalculateReservedSimpleInventory(
    "Mutation input"
    input: RecalculateReservedSimpleInventoryInput!
  ): RecalculateReservedSimpleInventoryPayload!

  "Update the SimpleInventory info for a product configuration"
  updateSimpleInventory(
    "Mutation input"
    input: UpdateSimpleInventoryInput!
  ): UpdateSimpleInventoryPayload!
}
