Skip to main content

Production Mutations

Mutations for managing production runs.

createProductionRun

Creates a new production run.

Arguments

"""
Input for creating a production run.
"""
input CreateProductionRunInput {
"""
When the production run starts.
"""
startDate: DateTime!

"""
Optional end date.
"""
endDate: DateTime

"""
Brand ID associated with the production.
"""
brandId: ID!

"""
Optional description.
"""
description: String

"""
Optional image URL for the production run.
"""
imageUrl: String

"""
Optional delivery location IDs.
"""
deliveryLocationIds: [ID!]

"""
Optional storage location IDs.
"""
storageLocationIds: [ID!]
}

Example Mutation

mutation CreateProductionRun {
createProductionRun(
input: {
startDate: "2023-01-01T00:00:00Z"
brandId: "123"
description: "Q1 Production Run"
imageUrl: "https://example.com/images/q1-production.jpg"
deliveryLocationIds: ["loc_456"]
storageLocationIds: ["store_789"]
}
) {
id
startDate
description
brand {
id
name
}
deliveryLocations {
id
name
}
storageLocations {
id
name
}
}
}

updateProductionRun

Updates an existing production run.

Arguments

"""
Input for updating a production run.
"""
input UpdateProductionRunInput {
"""
Optional new start date.
"""
startDate: DateTime

"""
Optional new end date.
"""
endDate: DateTime

"""
Optional new brand ID.
"""
brandId: ID

"""
Optional new description.
"""
description: String

"""
Optional new image URL.
"""
imageUrl: String

"""
Optional new delivery location IDs.
"""
deliveryLocationIds: [ID!]

"""
Optional new storage location IDs.
"""
storageLocationIds: [ID!]
}

Example Mutation

mutation UpdateProductionRun {
updateProductionRun(
id: "123"
input: {
endDate: "2023-12-31T23:59:59Z"
description: "Updated Q1 Production Run"
deliveryLocationIds: ["loc_789"]
}
) {
id
startDate
endDate
description
deliveryLocations {
id
name
}
}
}

deleteProductionRun

Deletes a production run.

Arguments

"""
ID of the production run to delete.
"""
id: ID!

Example Mutation

mutation DeleteProductionRun {
deleteProductionRun(id: "123")
}

Location Management Mutations

addDeliveryLocationToProductionRun

Adds a delivery location to a production run.

mutation AddDeliveryLocation {
addDeliveryLocationToProductionRun(
productionRunId: "123"
deliveryLocationId: "loc_456"
) {
id
deliveryLocations {
id
name
}
}
}

removeDeliveryLocationFromProductionRun

Removes a delivery location from a production run.

mutation RemoveDeliveryLocation {
removeDeliveryLocationFromProductionRun(
productionRunId: "123"
deliveryLocationId: "loc_456"
) {
id
deliveryLocations {
id
name
}
}
}

addStorageLocationToProductionRun

Adds a storage location to a production run.

mutation AddStorageLocation {
addStorageLocationToProductionRun(
productionRunId: "123"
storageLocationId: "store_456"
) {
id
storageLocations {
id
name
}
}
}

removeStorageLocationFromProductionRun

Removes a storage location from a production run.

mutation RemoveStorageLocation {
removeStorageLocationFromProductionRun(
productionRunId: "123"
storageLocationId: "store_456"
) {
id
storageLocations {
id
name
}
}
}

Error Handling

Common Errors

Error CodeDescription
PRODUCTION_RUN_NOT_FOUNDProduction run ID not found
BRAND_NOT_FOUNDBrand ID not found
LOCATION_NOT_FOUNDLocation ID not found
INVALID_DATE_RANGEEnd date before start date
INVALID_IMAGE_URLInvalid image URL format

Example Error Response

{
"errors": [
{
"message": "Production run not found",
"extensions": {
"code": "PRODUCTION_RUN_NOT_FOUND",
"id": "123"
}
}
]
}

Best Practices

  1. Date Management

    • Use ISO 8601 format
    • Validate date ranges
    • Handle timezones properly
  2. Location Management

    • Validate location existence
    • Handle location changes
    • Update related records
  3. Brand Association

    • Validate brand exists
    • Check brand permissions
    • Handle brand changes
  4. Security

    • Validate permissions
    • Audit changes
    • Log sensitive operations